vue2 slot 3个关键字 slot slot-scope v-slot 组件式api调用

vue2 slot 3个关键字 slot slot-scope v-slot

<abcApi v-slot="{ list }">
                <Select
                  v-model="person.aaa"
                  :disabled="isDisabled || showDisabled">
                  <Option v-for="item in list"
                          :value="item.code"
                          :key="item.code">{{ item.name }}</Option>
                 </Select>
              </abcApi>

v-slot="{ list }"

abcApi.vue

<template>
  <div>
    <slot :list="list"></slot>
  </div>
</template>

<script>
export default {
  components: {},
  props: {},
  data () {
    return {
      list: []
    }
  },
  watch: {},
  computed: {},
  methods: {},
  created () { },
  activated () { },
  mounted () {
    const params = { typeFlag: 'aaa', parentCode: '' }
    this.$api('/aaa', params).then(res => {
      if (res && res.status === 20) {
        this.list = res.data
      }
    })
  },
  beforeDestroy () { }
}
</script>

<style lang="less" scoped>
</style>

posted @ 2025-03-11 10:18  彭成刚  阅读(20)  评论(0)    收藏  举报