mpvue商品详情页面上次数据缓存

Others 2018-09-20 02:31:22 2018-09-20 02:31:22 3564 次浏览

cnpm install mpvue-page-factory

将main.js app.$mount()改为


import pageFactory from 'mpvue-page-factory'
import App from './index'
Page(pageFactory(App))

https://github.com/HelloZJW/mpvue-page-factory


或者


mpvue 页面切换数据缓存解决


onLoad () { Object.assign(this.$data, this.$options.data()) }


const dataArr = []

export default { onLoad() { Object.assign(this.$data, this.$options.data()) // fetch some data dataArr.push({ ...this.$data }) }, onUnload() { dataArr.pop() const dataNum = dataArr.length if (!dataNum) return Object.assign(this.$data, dataArr[dataNum - 1]) }, }