<el-select
v-model="ruleForm.listId"
v-loadmore="devLoadmore"
style="width:220px"
filterable
placeholder="请选择"
size="small"
clearable
>
<el-option
v-for="(item, index) in list"
:key="index"
:label="item.name"
:value="item.id"
/>
</el-select>
**
// 初始化添加数组
initResourcePage() {
return resourcePage({
...this.devArrForm
}).then(res => {
const { result } = res.data
this.vppDevListArrLength = res.data.total
let tempObj= result.find(item=> item.id=== this.templateInfo.id)
if (this.templateInfo.name&& !tempObj) {
this.list= [{
id: this.templateInfo.id,
name: this.templateInfo.name
}, ...result]
} else {
this.list= result
}
})
},
上拉函数
devLoadmore() {
if (this.list.length !== this.devArrLength - 1) {
this.devArrForm.page++
resourcePage({
...this.devArrForm
})
.then((res) => {
const { result } = res.data
this.devArrLength = res.data.total
for (let i = 0; i < result.length; i++) {
if (this.ruleForm.parentResourceId !== result[i].resourceId) {
this.list.push(result[i])
}
}
})
.catch(() => {})
}
},