给需要清空的值添加一个判断就行:
eg:
placeholder="请选择项目组"
clearable
@change="project_team_change"
>
:key="item._id"
:label="item.project_team_name"
:value="item._id">
placeholder="请选择项目"
clearable
>
:key="item._id"
:label="item.project_name"
:value="item._id">
async project_team_change(project_team_id) {
this.project_code_list = await this.$getProjectCodeInfo({'project_team_id': project_team_id});
if (this.pageData.project_id) {
this.pageData.project_id = '';
}
},
注:
// if (this.pageData.project_id) {
// let fields = this.$refs['pageDataRef'].fields;
// for (let i = 0; i < fields.length; i++) {
// if (fields[i].prop === 'project_id') {
// fields[i].resetField();
// break;
// }
// }
// }
原始写法,后来发现不需要这样复杂,只需要在第一次赋值中进行判断就行,最好是判断不为空即可