How does select in element choose before emptying after the drop-down data has changed?

as shown in figure 1, in the first drop-down selection, the second select is dynamically assigned,
1

2

select
3

I"m a little confused. During the novice trial, I don"t know how to clear the second

when the first select changes.
Mar.09,2021

listen for changes to the first select and change the value of the second select to null

use watch, like this

data(){
    return {
        form:{
            select1:null,
            select2:null
        }
        
    }
},
watch: {
    'form.select1': function (newValue, oldValue) {
        this.form.select2 = null
    }
},
methods:{
    ...
}

/ / emptying method (solves the problem that the value of the second select cannot be selected after emptying the first selection box value)
methods: {

resetValue(){
    this.$set(this.form, 'select1', '')
}

}


listens for the change event of the first seelect, clears the value of the second select binding, or assigns the first


just add a judgment to the value that needs to be cleared:
eg:

     <el-form-item label="" prop="project_team_id">
            <el-select v-model="pageData.project_team_id"
                       placeholder=""
                       clearable
                       @change="project_team_change"
            >
                <el-option v-for="item in project_team_code_list"
                           :key="item._id"
                           :label="item.project_team_name"
                           :value="item._id">
                </el-option>
            </el-select>
        </el-form-item>

        <el-form-item label="" prop="project_id">
            <el-select v-model="pageData.project_id"
                       placeholder=""
                       clearable
            >
                <el-option v-for="item in project_code_list"
                           :key="item._id"
                           :label="item.project_name"
                           :value="item._id">
                </el-option>
            </el-select>
        </el-form-item>

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 = '';
            }
        },
        
< hr >

Note:
/ / if (this.pageData.project_id) {
/ / let fields = this.$refs ['pageDataRef'] .fields;
/ / for (let i = 0; I < fields.length; iPP) {
/ / if (fields.prop =' project_id') {
/ / fields.fields ();
/ / break;
/ /}
original writing, later found that it does not need to be so complicated, only need to judge in the first assignment, it is best to judge not empty


_1590723281842.png

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37463-34449.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37463-34449.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?