同一个页面不同数据显示不同组件;同一个页面切换刷新数据;v-if实现页面内容切换

<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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值