-
-
Notifications
You must be signed in to change notification settings - Fork 150
Page elements mounted twice #80
Comments
PS: I just tested with older build, and the problem was not there before change on routing |
@scriptPilot - yes, that is odd. I notice that when I add a log to the about page itself, it only gets called once. export default {
mounted() {
console.log('About page mounted')
}
} Looks like something weird going on, so I'll see what I can find. |
Still haven't figured it out yet, but here are a couple of observations:
|
Actually, it doesn't seem to have anything to do with the new routing code. For instance, when I go back to 3d3993f, I can still reproduce it (mixin mount called twice in the kitchen sink). I went all the way back to c940248 and still see that the mixin mount is called twice. It seems bizarre that it gets called twice, but from what I can tell, it has worked like that for quite some time. @scriptPilot - can you verify what version you see the mixin mounted function get called only once? |
@bencompton - With release 0.7.8 it works fine - only one mounted() hook called |
@scriptPilot - from my tests, I have never been able to get it to only call mounted once from Vue.mixin. I just tried again and was able to reproduce the two calls with the instructions in your original post, which ended up being 0.7.7. Here are the steps I took:
So, I saw two calls happening in version 0.7.7, which was prior to PR #79 being merged (as is version 0.7.8). Earlier, I tested all the way back to version 0.6.x and never was able to reproduce It looks to me like the 2 calls from Even if it has been that way for a long time, it is still strange that it gets called twice. |
@bencompton - You are right. I checked before if there is a $route object - it seems, the page is mounted twice, the second time with $route object - maybe this has changed now and it's there at the first mount as well. preroute() will be called twice as well for each page load. |
Well, this took me a while to debug and find out the issue. So, actually it is not an issue and everything is correct. For example:
This custom page component returns single component So i can recommend not to rely on $el class in this case inside of |
@nolimits4web - yes, that makes perfect sense. Great work figuring that out! |
@nolimits4web - Thank you Vladimir, I change my if statement to:
Works again! Dennis |
I took the Webpack template and added the following mixin to the main.js file:
The result is, that there are allways two logs after I open a page, e.g. "About" page. Is there any reason?
The text was updated successfully, but these errors were encountered: