@wecity/qiankun-cache
v0.0.1
Published
qiankun缓存组建,实现类型vue中的keep-alive
Downloads
2
Maintainers
Keywords
Readme
@wecity/qiankun-cache
npm i @wecity/qiankun-cache -S
proxyMount
import { proxyMount } from '@wecity/qiankun-cache'
export function mount(props) {
router = Router.init(Vue, props)
const instanceFn = () => {
return new Vue({
router,
store,
render: h => h(App)
}).$mount(container ? container.querySelector('#app') : '#app')
}
const renderVNode = vnode => {
return new Vue({
router,
store,
render: () => vnode
}).$mount(container ? container.querySelector('#app') : '#app')
}
instance = proxyMount({
router,
instanceFn,
renderVNode
})
}
| 字段名 | 类型 | 描述 | | :---- | :--- | :--- | | router | object | 路由实例 | | instanceFn | function | 渲染函数 | | renderVNode | function | 缓存渲染函数 |
proxyUnmount
import { proxyUnmount } from '@wecity/qiankun-cache'
export function unmount() {
proxyUnmount({ instance })
instance.$destroy()
instance = null
router = null
}
| 字段名 | 类型 | 描述 | | :---- | :--- | :--- | | instance | object | 实例 |
注意
- 第二次进入闪屏问题: css、js打包在一起不要分别打包