<template>
<component
:is="currentView"
v-if="showPage" !!!!!!!//使用v-if直接从dom树去掉加上 起到刷新效果
/>
</template>
<script>
//俩个组件
import Form from "./form";
import List from "./list";
export default {
components: { Form, List },
data() {
return {
currentView: "",
showPage: false,
};
},
methods: {
getConfigData() {
getBizConfig()
.then((res) => {
//根据返回不同的数据显示不同的组件
if (res.data.webType == "1") {
this.currentView = "Form";
} else {
this.currentView = "List";
}
//新的组件页面显示
this.showPage = true; !!!!!!!
})
.catch(() => {});
},
},
watch:{
'$route.query.id':{
immediate:true,
deep:true,
handler(val){
//旧的页面显示关闭
this.showPage=false!!!!!!
this.getConfigData();
}
}
}
};
</script>
同一个页面不同数据显示不同组件;同一个页面切换刷新数据;v-if实现页面内容切换
于 2023-03-02 16:14:33 首次发布