我使用的是element-ui V2.2.3。代碼如下,當我選擇值得時候,el-select選擇器無法顯示選中的內容,但是能觸發change方法,并且能輸出選擇的值。
創新互聯公司主要從事網站建設、網站設計、網頁設計、企業做網站、公司建網站等業務。立足成都服務定安,十年網站建設經驗,價格優惠、服務專業,歡迎來電咨詢建站服務:18982081108
select.vue文件
<template> <div> <div class="row" v-for="RowItem in rows"> <div class="col" v-for="colItem in RowItem.configVos"> <el-select v-model="formData[colItem.paramCode]" :class="getModel(colItem.paramCode)" @change="onSelectChange(colItem.paramCode,formData[colItem.paramCode])"> <el-option v-for="option in colItem.configOptions" :label="option.optionCode" :value="option.optionValue" > </el-option> </el-select> </div> </div> </div> </template> <script> import axios from 'axios'; export default { data() { return { groupItem:{}, formData:{}, rows:'', cols:'' } }, watch:{ }, methods:{ getfordata:function(){ var _this = this; axios.get('../json/selectdata.json') .then(function(res){ _this.groupItem = res.data; var row = _this.groupItem[0].rowData; _this.rows = row; for(var i=0;i<row.length;i++){ var col = row[i].configVos; for(var j=0;j<col.length;j++){ var key = col[j]; _this.formData[key.paramCode] = ''; } } }) }, onSelectChange:function(key,val){ console.log(val); }, getModel(model) { console.log(model); } }, created:function(){ this.getfordata(); } } </script> <style scoped> .col{ float:left; } .row{ width:800px; height:100px; } </style>
selectdata.json文件
[ { "groupName": "抽數轉換", "rowData": [ { "configVos": [ { "configOptions": [ { "id": "D", "optionCode": "否", "optionValue": "0", "paramId": "4" }, { "id": "5", "optionCode": "是", "optionValue": "1", "paramId": "4" } ], "id": "4E", "paramCode": "isView", "paramValue": "0" }, { "configOptions": [ { "id": "4", "optionCode": "老版本", "optionValue": "0", "paramId": "4" }, { "id": "4", "optionCode": "新版本", "optionValue": "1", "paramId": "44" } ], "id": "24", "paramCode": "isDeleteCbnd", "paramValue": "1" } ] }, { "configVos": [ { "configOptions": [ { "id": "EF", "optionCode": "估值2.5", "optionValue": "0", "paramId": "1" }, { "id": "8B", "optionCode": "估值2.5+qd", "optionValue": "1", "paramId": "131" }, { "id": "06", "optionCode": "恒生2.5", "optionValue": "2", "paramId": "1" }, { "id": "25BF", "optionCode": "估值4.5", "optionValue": "3", "paramId": "31" } ], "id": "31", "paramCode": "converType", "paramValue": "0" }, { "configOptions": [ { "id": "1366", "optionCode": "萬德", "optionValue": "0", "paramId": "98" }, { "id": "EC", "optionCode": "聚源", "optionValue": "1", "paramId": "8" } ], "id": "91F8", "paramCode": "zxDataSource", "paramValue": "0" } ] }, { "configVos": [ { "configOptions": [ { "id": "CD", "optionCode": "期貨占用", "optionValue": "HS", "paramId": "5C" }, { "id": "91508011", "optionCode": "其它", "optionValue": "YYS", "paramId": "91C" } ], "id": "5C", "paramCode": "derivativeDataSource", "paramValue": "HS" } ] } ] } ]
后來去看了Vue文檔,發現文檔中有說
我只是把下面綠色那句改成上面紅色這句,就好了
總結
以上所述是小編給大家介紹的vue2.0 element-ui中el-select選擇器無法顯示選中的內容,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對創新互聯網站的支持!
當前名稱:vue2.0element-ui中el-select選擇器無法顯示選中的內容(解決方法)
網站網址:http://m.newbst.com/article12/ispigc.html
成都網站建設公司_創新互聯,為您提供面包屑導航、服務器托管、域名注冊、營銷型網站建設、品牌網站設計、網站營銷
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯