代码拉取完成,页面将自动刷新
<template>
<el-select
v-model="dictValue"
style="width: 100%"
:size="size"
:placeholder="placeholder"
@change="change"
>
<el-option
v-for="item in dictList"
:key="item.num"
:label="item.name"
:value="item.num"
/>
</el-select>
</template>
<script>
import dictApi from '@/api/system/dict'
export default {
name: 'DictSelect',
props: {
value: {
type: [String, Number],
default: ''
},
size: {
type: String,
default: 'mini'
},
dictName: {
type: String,
default: '',
require: true
},
placeholder: {
type: String,
default: ''
}
},
data() {
return {
dictList: [],
dictValue: ''
}
},
watch: {
value() {
this.dictValue = this.value + ''
}
},
created() {
this.dictValue = this.value + ''
this.getDictList()
},
methods: {
getDictList() {
// 从后台获取字典列表
dictApi.getDicts(this.dictName).then(response => {
this.dictList = response.data
})
},
change(value) {
this.$emit('input', value)
}
}
}
</script>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。