ivanlee93 / mpvue-cli

对mpvue官方quick-start的模版进行优化改造,更新
41 stars 3 forks source link

页面跳转 OnLoad 为什么会触发两次? #2

Closed qingwatianya closed 4 years ago

qingwatianya commented 6 years ago

hello 请教一下 pages 文件夹下的 index.vue 和 counter.vue 页面来回跳转的时候 页面 OnLoad 函数 会触发2次 为啥?

ivanlee93 commented 6 years ago

hello 请教一下 pages 文件夹下的 index.vue 和 counter.vue 页面来回跳转的时候 页面 OnLoad 函数 会触发2次 为啥?

我测试了一下, 是mpvue-page-factory这个插件导致的, 我等会把它去掉, 手动配置你可以看一下作者的README https://github.com/HelloZJW/mpvue-page-factory

ivanlee93 commented 6 years ago

hello 请教一下 pages 文件夹下的 index.vue 和 counter.vue 页面来回跳转的时候 页面 OnLoad 函数 会触发2次 为啥?

重新初始化代码就可以解决了

qingwatianya commented 6 years ago

哈哈 谢谢 谢谢 爱思你了! 原来是 template: './src/template.js'//多了这一句 const entry = MpvueEntry.getEntry({ pages: './src/pages.js', main: './src/main.js', template: './src/template.js'//多了这一句 })
天知道当我准备用这个架构开发小程序的时候 发现OnLoad()会加载两次的时候 那种纠结的强迫感觉 用呢还是不用呢 哈哈 谢谢!