element 获取下拉框key和value

获取下拉框key和value
更新写法:ref=“”

     el-form-item label="杆塔编号" prop="gtbh">
          
            
          
      

取值:

        this.form.towerId=this.$refs.ganta.selectedLabel;
        this.form.lineName=this.$refs.line.selectedLabel;
写法一:

   
      
    

  queryTower (val) {
      this.form.lineName = this.allxlist.filter(item => item.obiId === val)[0].lineName;
      this.allgtList = [];
      this.axios.post("/mXttzGtrunDatas/queryTower", { lineId: [val] }
      ).then(({ data }) => {
        this.allgtList = data.resultValue;
      })
    },
写法二:
 
    
          
        

  towChange (val) {
    let choosenItem = this.allgtList.filter(item => item.objId === val);
    this.form.towerName = choosenItem[0].objId;
    this.form.towerId = choosenItem[0].objOrder;
  },

你可能感兴趣的:(vue.js,javascript,前端)