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è)參考,也希望大家多多支持腳本之家。
相關(guān)文章
element-resize-detector監(jiān)聽(tīng)普通元素的實(shí)現(xiàn)示例
當(dāng)涉及到網(wǎng)頁(yè)元素的實(shí)時(shí)尺寸變化監(jiān)測(cè)時(shí),element-resize-detector?是一個(gè)值得推薦的開(kāi)源庫(kù),本文主要介紹了element-resize-detector監(jiān)聽(tīng)普通元素的實(shí)現(xiàn)示例,感興趣的可以了解一下2024-07-07
vue路由$router.push()使用query傳參的實(shí)際開(kāi)發(fā)使用
在vue項(xiàng)目中我們用函數(shù)式編程this.$router.push跳轉(zhuǎn),用query傳遞一個(gè)對(duì)象時(shí)要把這個(gè)對(duì)象先轉(zhuǎn)化為字符串,然后在接收的時(shí)候要轉(zhuǎn)化為對(duì)象,下面這篇文章主要給大家介紹了關(guān)于vue路由$router.push()使用query傳參的實(shí)際開(kāi)發(fā)使用,需要的朋友可以參考下2022-11-11
vue獲取當(dāng)前日期時(shí)間(使用moment和new?Date())
在項(xiàng)目開(kāi)發(fā)中我遇到了日期范圍選擇器,兩種獲取當(dāng)前日期并做處理的寫法,這里記錄一下,下面這篇文章主要給大家介紹了關(guān)于vue獲取當(dāng)前日期時(shí)間(使用moment和new?Date())的相關(guān)資料,需要的朋友可以參考下2023-06-06
vue實(shí)現(xiàn)登錄滑動(dòng)拼圖驗(yàn)證
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)登錄滑動(dòng)拼圖驗(yàn)證,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03
vue.js基于v-for實(shí)現(xiàn)批量渲染 Json數(shù)組對(duì)象列表數(shù)據(jù)示例
這篇文章主要介紹了vue.js基于v-for實(shí)現(xiàn)批量渲染 Json數(shù)組對(duì)象列表數(shù)據(jù),結(jié)合實(shí)例形式分析了vue.js使用v-for遍歷json格式數(shù)據(jù)渲染列表相關(guān)操作技巧,需要的朋友可以參考下2019-08-08
Vue3+Element?Plus按需引入(自動(dòng)導(dǎo)入)詳解
element-plus根據(jù)官網(wǎng)文檔,推薦用戶采用按需導(dǎo)入的方式進(jìn)行導(dǎo)入,下面這篇文章主要給大家介紹了關(guān)于Vue3+Element?Plus按需引入(自動(dòng)導(dǎo)入)的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-10-10
解決vue項(xiàng)目獲取dom元素寬高總是不準(zhǔn)確問(wèn)題
這篇文章主要介紹了解決vue項(xiàng)目獲取dom元素寬高總是不準(zhǔn)確問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-07-07

