借鉴于 https://blog.csdn.net/qq_40323256/article/details/103414198 局部刷新
1. 首先需要修改路由出口App.vue
<template>
<div id="app">
<router-view v-if="localNeed"/>
</div>
</template>
<script>
export default {
provide(){
return{
reload:this.reload
}
},
data(){
return{
localNeed:true
}
},
methods:{
reload () {
this.localNeed = false
this.$nextTick(() => {
this.localNeed = true
})
}
}
}
</script>
2. 到需要 i18n 语言切换 的 echarts 页面 导入 i18n
import i18n from '@/lang/index' // i18n 配置 根据自己项目存放的位置
3.使用inject导入引用reload,在data里对i18n里赋值
export default {
inject: ['reload'], // 局部刷新
data () {
return {
i18n: i18n
}
}
4.在watch深度监听 i18n 语言的切换