vue 封装高级技巧

1. 组件 如何透传属性和事件  v-bind="$attrs"   v-on="$listeners"
2. 封装table组件如何循环传子元素  $scopedSlots 子元素数组

      <template v-for="(index, name) in $scopedSlots" v-slot:[name]="slotProps">
            <slot :name="name" v-bind="{slotProps}"></slot>
        </template>
3. 日常 表单 例如 图片上传 没有提供v-modal怎么办
  自定义v-modal  内部声明

 

  model: {
      prop: 'value',
      event: 'change'
    },

  事件中调用

this.$emit('change', this.fileList);即可更新v-modal  处罚form自动校验更新

 

posted @ 2021-10-01 16:47  廖龙飞  阅读(191)  评论(0编辑  收藏  举报