Vue+Element+Select獲取選中的對象


              

 

案例演示:獲取select當前選中的所有內容

 

 

1 <el-select v-model="value8" filterable placeholder="請選擇" value-key="id" @change="currentSel">
2    <el-option v-for="item in options" :key="item.id" :label="item.label" :value="item"></el-option>
3 </el-select>

 

 1       options: [
 2         {
 3           value: "選項1",
 4           id: 1,
 5           code: "xuanxiang1",
 6           label: "黃金糕"
 7         },
 8         {
 9           code: "xuanxiang2",
10           id: 2,
11           value: "選項2",
12           label: "雙皮奶"
13         },
14         {
15           id: 3,
16           value: "選項3",
17           code: "xuanxiang3",
18           label: "蚵仔煎"
19         },
20         {
21           value: "選項4",
22           id: 4,
23           code: "xuanxiang4",
24           label: "龍須面"
25         },
26         {
27           value: "選項5",
28           label: "北京烤鴨",
29           id: 5,
30           code: "xuanxiang5"
31         }
32       ],

 

1 currentSel(selVal) {
2       this.code = selVal.code;
3       this.name = selVal.label;
4       console.log("選擇的name為:" + this.name, "選擇的code為:" + this.code);
5       console.log(selVal);
6     },

 

若有不明白請加群號:復制 695182980 ,也可掃碼,希望能幫助到大家。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM