Vue-动态组件

Vue 中我们可以通过 < component> 元素加一个特殊的 is 属性来实现当前使用哪一个组件,可以用来渲染自定义的组件

<component :is="item.component" :data.sync="item" @jump="handleJump" />
export const modules = [
  {
    id: 0,
    moduleFlag: 'image',
    component: 'MyImage', // MyImage是自定义组件名称,可以自定义也可以通过上传到npm上安装到项目中
    imgUrl: '1.png',
    style: { backgroundColor: 'rgba(255, 255, 255, 0)'}
  },
]

你可能感兴趣的:(vue.js)