我想实现的功能是,我的option从后台数据库拿的数据,当我点击 el-select选项框时才开始调后台数据接口,让option显示出来。但是我现在在el-select增加了 @click="getInvestInfo()" 点击时间,却并没有效果,
<el-select v-model="form.investor" placeholder="请选择投资人" @click="getInvestInfo()">
<el-option v-for="item in getInvestorsInfo"
:key="item.invest_username"
:label="item.invest_username"
:value="item.investuser_id">
</el-option>
</el-select>
methods: {
getInvestInfo(){
let uid = sessionStorage.getItem('uid');
var params = new URLSearchParams();
params.append('is_iso', '1');
params.append('uid', uid);
this.$axios({
method: 'post',
url:httpUrl.InvestUserList,
data:params,
}).then((res)=>{
console.log(res.data);
if(res.data.errCode==0){
this.getInvestorsInfo = res.data.retData;
}else if(res.data.errCode==1){
this.$message.error(res.data.retData.msg);
}else if(res.data.errCode==2){
this.$router.push('/login');
}
});
}
}
getInvestInfo方法放在created里面是可以的 ,但不是我想要的效果 ,我只想在点选项的时候,才去调接口,而不是进页面的时候就调select的接口
created(){
// this.getInvestInfo();
},
问题应该是没有进去这个点击的方法 console也打不出来
el-select中click事件无效,用focus方法