vue写的前端,iviewui里面的下拉框组件,官方文档说clearable可以清空选择,于是用了,但发现,在请求后端接口后,该参数就不传递了,之前传递的是空字符串
这是定义 sysSearchInfo: { sysName: '', applicationJenkinsDevJob: '', sysTeamLeader: '' }
这是开始用clearable后的传参
{"applicationJenkinsDevJob":"xxxx","sysTeamLeader":"yyyy"}
我们想要的传参
{"sysName":"","applicationJenkinsDevJob":"xxxx","sysTeamLeader":"yyyy"}
代码:
<Select v-model="sysSearchInfo.sysName" clearable filterable placeholder="搜索系统" @on-change="selectClear('sysName')"> <Option v-for="sysName in systemNameList" :value="sysName" :key="sysName">{{ sysName }} </Option> </Select>
selectClear(res) { if (this.sysSearchInfo[res] == undefined) { this.sysSearchInfo[res] = '' } },
总结就是用on-change方法,on-clear方法对于我来说不管用。