Hook function of Vue [route navigation guard, keep-alive, life cycle hook]

> some knowledge about hooks: Using keep-alive, beforeDestroy is not called.Component hooks before destruction) and destroyed (component destruction), because components are not destroyed and cached. This hook can be seen as an alternative to beforeDestroy, and if you cache a component, you can do something when the component is destroyed, you can put it in this hook. If you leave the route, it will trigger in turn. Inside the component, leave the current routing hook beforeRouteLeave => route front guard beforeEach =>Global post hook afterEach => deactivated leaveCache compone...

Using mpvue to develop small programs how to define global variables

After we created the mpvue project, we found src/main.js and added a line of code behind it. (Note: cannot be added before const app = new Vue (App). Vue.prototype.globalData = getApp().globalData This line of code means that the global variables of the applet are mounted on the Vue prototype so that we can get the global data on different pages Different pages can be acquired or modified by this.globalData. For example, I need to store some basic information of users. this.globalData.userInfo = {name:aaa} Different pages get the same way. console.log(this.globalData.userInfo.name) modify...