vue多个自定义组件动态显示

html部分

通常写法:

通过<physical-result></physical-result>显示在页面上

动态引入写法:<component :is="currentView"></component>

 

script部分

先导入组件

import PhysicalResult from '../views/Setting/PhysicalResult.vue'
components:{
    'physical':PhysicalResult
  },
 
data中定义一个数组
componentList:['physical']
 
computed中
currentView(){
      return this.componentList[0]
    }
 
 
 
来源:https://dongfangyou.blog.csdn.net/article/details/105842267?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.highlightwordscore&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.highlightwordscore
 
posted @ 2021-12-24 09:45  埃菲尔上的加菲猫  阅读(267)  评论(0编辑  收藏  举报