作者:崔显莉京_716 | 来源:互联网 | 2023-06-09 14:50
下拉框中的数据是从后台获取到的数据,将后台传来的重复数据只保留一个
filterable
placeholder="请选择品规"
v-model="queryObj.production"
>
v-for="item in productionObj"
:key="item.productId"
:label="item.productDesc"
:value="item.productId"
>
export default {
data () {
return {
queryObj: {
company: '', //工业公司
}
}
},
methods: {
unique(arr) {
const res = new Map();
return arr.filter((arr) => !res.has(arr.supplierCode) && res.set(arr.supplierCode, 1));
},
// 获取工业公司
handleQuaryCompany() {
const _this = this
findSupplierInfo().then(req => {
_this.companyObjAll = req.data
this.companyObj = this.unique(_this.companyObjAll)
})
}
}
}
jQuery遍历-has()方法将匹配元素集合缩减为拥有匹配指定选择器或DOM元素的后代的子集。