element下拉選單 command 傳遞多個值
阿新 • • 發佈:2021-01-15
element
的下拉選單 command
傳遞多個值
核心程式碼:
<el-dropdown-item :command="{row:boy, command:'1'}">傳多個值</el-dropdown-item>
完整程式碼:
<el-dropdown @command="handleCommand">
<span class="el-dropdown-link">
下拉選單<i class="el-icon-arrow-down el-icon--right" ></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="a">黃金糕</el-dropdown-item>
<el-dropdown-item command="b">獅子頭</el-dropdown-item>
<!-- 像這樣傳遞多個值: -->
<el-dropdown-item :command= "{row:boy, command:'1'}">傳多個值</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<script>
export default {
data(){
boy: {name:'Tom', age:22}
},
methods: {
handleCommand(command) {
this.$message('click on item ' + command);
}
}
}
</script>