Focus onThe front small Ou, read more original technical articles
Because has been using the VUE technology stack, so the first development of small programs to try to use [MPVUE]. Although hearing the framework has stopped maintenance, in order to get started quickly, regardless of the possible existence of many bugs, decided to use.
Sure enough, a big bug popped up: when the same route was switched, the data from the previous page would be preserved
Project actual combat bugs:MPVue refactors the CNode community
GitHub users have given related reasons on MPVue issues:
Referring to many answers, using the method of “building page stack” to solve:
const dataStack = []; Export default {data () {return {... }; }, onLoad () { dataStack.push({ ... this.$data }); // backup data // other initialization.... }, onUnload () {Object.assign(this.$data, datastack.pop ()); // restore data}}
Because the code in Vue’s mixin executes before the page, the above method can be optimized into the mixin.js file
Let mixin = {data() {return {dataStack: [], // Set up a stack stack for the same component in the mpvue}; }, onUnload() { Object.assign(this.$data, this.dataStack.pop()); // restore}, onLoad() {this.datastack.push ({... JSON.parse(JSON.stringify(this.$data)) }); // backup},}; export default mixin;
Bug solved:
For complete code of functions and projects, see Simon -cnode (MPVUE refactoring cnode community). Welcome STAR!