Vue之elementUI下拉菜單dropdown組件中command方法添加額外參數(shù)方式
elementUI下拉菜單dropdown組件中command方法添加額外參數(shù)
在使用dropdown組件的時(shí)候,需要的參數(shù)可能很多,不僅僅是command一個(gè)參數(shù)。
這就需要通過(guò)composeValue構(gòu)造一個(gè)結(jié)構(gòu)了
<el-dropdown @command="handleCommand">
<el-dropdown-menu slot="dropdown">
<template v-for="item in items">
<el-dropdown-item v-for="it in item " :command="composeValue(it,scope.row)"/>
</template>
</el-dropdown-menu>
</el-dropdown>
//方法部分的處理
handleCommand(command) {
console.log(command)
},
composeValue(item, id) {
return {
button: item,
id: id
}
}打印結(jié)果

- table中

<el-table-column label="操作" width="250" fixed="right">
<template slot-scope="scope">
<el-button type="success" @click.stop="goPutin(scope.row)"
>編輯投放列表</el-button
>
<el-dropdown
@command="(command) => handleCommand(command, scope.row)"
>
<el-button type="primary"
>更多菜單<i class="el-icon-arrow-down el-icon--right"></i
></el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="remake">備注</el-dropdown-item>
<el-dropdown-item command="edit">編輯產(chǎn)品</el-dropdown-item>
<el-dropdown-item command="changeSort">排序</el-dropdown-item>
<el-dropdown-item command="remove">刪除</el-dropdown-item>
<el-dropdown-item command="overHz">{{
scope.row.productCooperation == 1 ? "終止合作" : "恢復(fù)合作"
}}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
<script>
// 更多操作觸發(fā)
handleCommand(command, row) {
switch (command) {
case "remake":
this.remake(row);
break;
case "edit":
this.edit(row);
break;
case "changeSort":
this.changeSort(row);
break;
case "remove":
this.remove(row);
break;
case "overHz":
this.overHz(row);
break;
default:
break;
}
},
edit(row) {
this.$nextTick(() => {
this.productId = row.productId;
this.goodsType = "edit";
this.$refs.goodsAdd.dialogVisible = true;
});
},
</script>總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- vue3+elementUI如何動(dòng)態(tài)修改Loading中提示文字
- Vue2集成ElementUI實(shí)現(xiàn)左側(cè)菜單導(dǎo)航功能
- Vue+elementUI導(dǎo)出word打印方式
- 手寫(xiě)實(shí)現(xiàn)vue2下拉菜單dropdown組件實(shí)例
- vue中使用el-dropdown方式
- Vue.js 帶下拉選項(xiàng)的輸入框(Textbox with Dropdown)組件
- 關(guān)于vue-cli-service:command?not?found報(bào)錯(cuò)引發(fā)的實(shí)戰(zhàn)案例
相關(guān)文章
vue中使用echarts以及簡(jiǎn)單關(guān)系圖的點(diǎn)擊事件方式
這篇文章主要介紹了vue中使用echarts以及簡(jiǎn)單關(guān)系圖的點(diǎn)擊事件方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-06-06
利用vue+elementUI實(shí)現(xiàn)部分引入組件的方法詳解
這篇文章主要給大家介紹了關(guān)于利用vue+elementUI實(shí)現(xiàn)部分引入組件的相關(guān)資料,以及介紹了vue引入elementUI報(bào)錯(cuò)的解決方法,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友可以參考借鑒,下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。2017-11-11
vue input輸入框關(guān)鍵字篩選檢索列表數(shù)據(jù)展示
這篇文章主要為大家詳細(xì)介紹了vue input輸入框關(guān)鍵字篩選檢索列表數(shù)據(jù)展示,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-05-05
vue3使用localStorage實(shí)現(xiàn)登錄注冊(cè)功能實(shí)例
這篇文章主要給大家介紹了關(guān)于vue3使用localStorage實(shí)現(xiàn)登錄注冊(cè)功能的相關(guān)資料, localStorage這個(gè)特性主要是用來(lái)作為本地存儲(chǔ)來(lái)使用的,解決了cookie存儲(chǔ)空間不足的問(wèn)題,需要的朋友可以參考下2023-06-06
Vue中點(diǎn)擊active并第一個(gè)默認(rèn)選中功能的實(shí)現(xiàn)
這篇文章主要介紹了Vue中點(diǎn)擊active并第一個(gè)默認(rèn)選中功能的實(shí)現(xiàn)代碼,代碼簡(jiǎn)單易懂,非常不錯(cuò)具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-02-02
vue3使用Electron打包成exe的方法與打包報(bào)錯(cuò)解決
在前端開(kāi)發(fā)中,Electron是一種常用的工具,它允許開(kāi)發(fā)者使用Web技術(shù)構(gòu)建桌面應(yīng)用程序,本文主要介紹了vue3使用Electron打包成exe的方法與打包報(bào)錯(cuò)解決,具有一定的參考價(jià)值,感興趣的可以了解一下2024-06-06
Vue通過(guò)getAction的finally來(lái)最大程度避免影響主數(shù)據(jù)呈現(xiàn)問(wèn)題
這篇文章主要介紹了Vue通過(guò)getAction的finally來(lái)最大程度避免影響主數(shù)據(jù)呈現(xiàn),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-04-04

