<template>
<el-select
class="mr__m"
:value="value"
placeholder="请先选择分类"
filterable
@input="change($event)"
>
<el-option
v-for="(option, index) in list"
:key="'categoryOptions' + index"
:label="option.dictValue"
:value="option.dictKey"
/>
</el-select>
</template>
<script>
export default {
props: {
list: {
type: Array,
default: _ => []
},
value: {
type: [String, Object]
}
},
methods: {
change(val) {
this.$emit('input', val)
}
}
}
</script>
这种封装方式是不是违背了数据单项流动的原则?好一点的写法应该是怎么样的?
谢谢。