The value of v-model in element-ui has changed, and the display of the interface has not changed. What's the problem?

when using vue+element, v-model binds an object attribute to the select element value. When you switch the select option, the bound object value changes, but the interface display remains unchanged, and it is still the option name corresponding to the original value.

<template>
    <div class="bg-hks-container">
        <div class="bg-hks-conditionbox">
            <el-row :gutter="10">
                <el-col 
                  class="bg-hks-condition-col"
                  :xs="24" :sm="12" :md="8" :lg="6" :xl="4" 
                  v-for="item in conditionitems"
                  :key="item.property"
                  >
                    <div class="bg-hks-condition-itembox">
                        <div class="bg-hks-condition-itemname">{{item.name}}:</div>
                        <el-date-picker
                          size="mini"
                          :placeholder="item.placeholder"
                          :type="item.type"
                          v-model="conditions[item.property]"
                          v-if="item.type==="date"||item.type==="datetime""
                        >
                        </el-date-picker>   
                        <el-input
                          size="mini"
                          :placeholder="item.placeholder"
                          :type="item.type"
                          v-model="conditions[item.property]"
                          v-if="item.type==="text""
                        >
                        </el-input>
                        <el-select
                          size="mini"
                          :placeholder="item.placeholder"
                          :type="item.type"
                          v-model="conditions[item.property]"
                          v-if="item.type==="select""
                        >
                            <el-option
                               v-for="opt in item.options"
                               :key="opt.value"
                               :label="opt.name"
                               :value="opt.value">
                            </el-option>
                        </el-select>
                    </div>
                </el-col>
            </el-row>
        </div>
        <table id="dataTable"></table>
    </div>
</template>
<script>
    export default {
        data(){
            return {
                apis:{},
                conditions:{},
                conditionitems:[]
            }
        },
        created(){
            this.initDataForCreate();
        },
        methods:{
            initDataForCreate(){
                this.apis = this.$store.state.apis;
                this.initCondition();
            },
            initCondition(){
                if(this.apis&&this.apis.hotkeycondition){
                    this.$http.get(this.apis.hotkeycondition)
                    .then(response=>{
                        if(response&&response.data){
                            this.conditionitems = response.data;
                        }else{
                            throw "ITEM";
                        }
                    })
                    .catch(error=>{
                        console.error(error);
                    });
                }else{
                    console.error("")
                }
            }
        },
        watch:{
            conditionitems(){
                if(this.conditionitems.length>0){
                    this.conditionitems.forEach(item=>{
                        this.conditions[item.property] = item.default;
                        if(item.type==="date"||item.type==="datetime"){
                            let date = new Date(item.default);
                            this.conditions[item.property] = date.toString()==="Invalid Date"
                                                           ? new Date()
                                                           : date;
                        }
                    })
                }
            }
        }
    }
</script>
<style lang="less" scoped>
Apr.03,2021

vue2.x (Object.definePropertype ()) listeners are not worth changing in objects. Vue3.X has redesigned the principle of data snooping from the underlying (proxy) so that it can monitor any changes that are worth changing. For this problem, the solution is as follows

  1. vMurmodel = "xxx" instead of vMurmodel = "xxx.xxx"
  2. use upgrade Vue3 build version, company project to upgrade carefully, personal demo at will
  3. still use the existing vmurmodel = "xxx.xxx". For assignment, please use this.$set (xxx, 'attr', value);
  4. ).

if the above is not possible,

  1. Please check carefully whether there is a definition in data, for example, VMI model = "obj.timeStart" in the template

but only the outer obj= {} is written in data. It is recommended to complete it, that is, obj= {timeStart:'};

  1. check to see if your lifecycle from beforeCreate to mounted performs the operation of emptying the value of v-model.

I hope I can help you


I remember that it seems that the model of select is the same as the value of option or the value of option. I don't remember which one. Try


I also encountered this problem. Have you solved it?


I switched to iView

later.
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-1e445bb-44aa3.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-1e445bb-44aa3.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?