vue刷新当前页面的好方法
<template>
<div id="app">
<router-view v-if="isRouterAlive" />
</div>
</template>
<script>
export default {
name: 'App',
provide () { //父组件中通过provide来提供变量,在子组件中通过inject来注入变量。
return {
reload: this.reload
}
},
data() {
return{
isRouterAlive: true //控制视图是否显示的变量
}
},
methods: {
reload () {
this.isRouterAlive = false; //先关闭,
this.$nextTick(function () {
this.isRouterAlive = true; //再打开
})
}
}
}
</script>

2.在需要刷新的页面
<script>
export default {
inject:['reload'],
data () {
return {
lists:[],
}
},
created () {
},
methods: {
// 删除
deleteBtn (index) {
let arr = this.common.getItem('sendData')
arr.splice(index,1)
this.common.setItem('sendData',arr)
this.reload();
},
}
}
</script>

2089

被折叠的 条评论
为什么被折叠?



