<el-form-item label="省" prop="cityName">

                    <el-select v-model="editForm.pid" placeholder="请选择省" class="handle-select mr10" @change="getCity">

                        <el-option

                            v-for="item in provinceItem"

                            :key="item.id"

                            :label="item.name" 

                            :value="item.id">

                        </el-option>

                    </el-select>

                </el-form-item>

                <el-form-item label="市" prop="cityName">

                    <el-select ref="cityId" v-model="editForm.cityId" placeholder="请选择市" class="handle-select mr10" clearable>

                    

                        <el-option

                            v-for="item in cityItem"

                            :key="item.id"

                            :label="item.name"

                            :value="item.id">

                        </el-option>

                    </el-select>

                </el-form-item>

 

代码如上,现在的问题是这样:省市都能正常出来,联动也实现,就是在选择省的时候市的下拉框应该清空上一次的选择,我用this.cityId = '',this.editForm.cityId = '',this.cityId = null这些都试过,都无法清空,请问是什么问题呢?

上面的问题,答案如下 

在获取城市方法的第一行,加入下面的代码就解决了 

this.$set(this.editForm, 'cityId', '')

 

Logo

前往低代码交流专区

更多推荐