element 获取下拉框key和value
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
免费下载资源
·
获取下拉框key和value
更新写法:ref=“”
el-form-item label="杆塔编号" prop="gtbh">
<el-select v-model="form.towerName" filterable size="medium" clearable placeholder="请选择杆塔编号" ref="ganta" >
<el-option v-for="(item,index) in gtbhOptions" :key="index" :label="item.objOrder" :value="item.objId"></el-option>
</el-select>
</el-form-item>
取值:
this.form.towerId=this.$refs.ganta.selectedLabel;
this.form.lineName=this.$refs.line.selectedLabel;
写法一:
<el-form-item label="所属线路" label-width="120px">
<el-select v-model="form.lineId" placeholder="所属线路" @change="queryTower" clearable>
<el-option v-for="(item,index) in allxlist" :key="index" :label="item.lineName" :value="item.obiId"></el-option>
</el-select>
</el-form-item>
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;
})
},
写法二:
<el-form-item label="所属杆塔" label-width="120px">
<el-select v-model="form.towerName" placeholder="所属杆塔" @change="towChange" clearable>
<el-option v-for="(item,index) in allgtList" :key="index" :label="item.objOrder" :value="item.objId"></el-option>
</el-select>
</el-form-item>
towChange (val) {
let choosenItem = this.allgtList.filter(item => item.objId === val);
this.form.towerName = choosenItem[0].objId;
this.form.towerId = choosenItem[0].objOrder;
},
GitHub 加速计划 / eleme / element
54.06 K
14.63 K
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:2 个月前 )
c345bb45
6 个月前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 7 个月前
更多推荐
已为社区贡献5条内容
所有评论(0)