wangzhibo
2026-07-16 b57020623cf0c946706573bf102e548c3a544423
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<template>
    <!--【很重要】直接绑定表单值 scope[prop] -->
    <!-- !符号,只是为了类型提示不错误 -->
    <el-select v-model="scope[prop!]" multiple>
        <el-option
            v-for="(item, index) in list"
            :key="index"
            :label="item.label"
            :value="item.label"
        />
    </el-select>
</template>
 
<!--【很重要】必须要有name,避免注册后和其他冲突 -->
<script setup lang="ts">
defineOptions({
    name: 'select-labels'
});
 
import { ref } from 'vue';
 
const props = defineProps({
    scope: null, // 表单值
    prop: String // 表单项配置的 prop
});
 
// 选项列表
const list = ref<{ label: string; value: string }[]>([
    {
        label: '帅气',
        value: '帅气' // 测试直接使用label,真实情况可能是1,2,3,4或者id
    },
    {
        label: '多金',
        value: '多金'
    },
    {
        label: '深情',
        value: '深情'
    }
]);
</script>