首先 index.ts 中定义枚举文章来源:https://www.toymoban.com/news/detail-628658.html
export const fruit= [
{
key:1,
name:'苹果',
},
{
key:11,
name:'草莓'
},
{
key:5,
name:'香蕉',
},
{
key:51,
name:'葡萄',
},
{
key:6,
name:'橙子'
},
{
key:7,
name:'哈密瓜'
},
{
key:10,
name:'西瓜'
},
];
接口返给的数据是一个对象文章来源地址https://www.toymoban.com/news/detail-628658.html
feeMap{
1:200,
2:100
}
const demand = reactive([])
fruit.forEach(item=>{
for (let key in feeMap.value) {
if (item.key == key as any) {
item.value = feeMap.value[key]
}else if(item.value == "" || item.value== undefined){
item.value = "--"
}else{
}
}
})
demand.push(...fruit)
到了这里,关于vue3+ts 实现枚举的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!