framework7io / framework7-vue

Deprecated! Build full featured iOS & Android apps using Framework7 & Vue
http://framework7.io/vue/
MIT License
674 stars 151 forks source link

First page is loaded twice, when pushState=true and pushStateSeparator='' #430

Closed cyberbeat closed 5 years ago

cyberbeat commented 6 years ago

This is a (multiple allowed):

What you did

var mainView = app.views.create('.view-main', {
    pushState: true,
    pushStateSeparator: '',
..

Expected Behavior

On app-load the first page should not be loaded again with ajax, because it is already included in html layout.

Actual Behavior

I debugged in framework7 code, and found out that in "Router.prototype.init" this line is called router.history = [documentUrl.split(router.params.pushStateSeparator)[0] || '/', initUrl]; here the history is filled up with '/' and the initUrl (which is not '/', but that is not important) Because of that, a few lines further historyRestored = true; is set. This seems to cause the initial page to be loaded twice.

nolimits4web commented 6 years ago

On app-load the first page should not be loaded again with ajax, because it is already included in html layout.

sounds like missconfiguration, if it loads page again then it considers it as a different route. Would be good to see full example, better live example.

cyberbeat commented 6 years ago

See here (f7 v.2.3.0), with some console.log output: https://www.wordwar.org/f7bugs/index.php

nolimits4web commented 6 years ago

Two things i see first:

Your pushStateRoot must be set to jut /f7bugs/ Your initial view url must be set to index.php

cyberbeat commented 6 years ago

Your documentation of pushStateRoot says:

Push state root URL separator, for example "http://my-app.com/". It is useful only in case when you use empty ("") pushStateSeparator

And the documentation for the initial view url (views.create Parameter) says:

Default (initial) View's url. If not specified, then it is equal to document url

I thought that index.php was the document-url

But nontheless your hint seems to fix the issue :-)

cyberbeat commented 6 years ago

Perhaps you could also have a look in the same example for the push-state-append problem?