vue中使用el-dropdown方式
更新時間:2022年08月15日 09:26:12 作者:吳小花的博客
這篇文章主要介紹了vue中使用el-dropdown方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
vue 使用el-dropdown

點(diǎn)擊【更多】彈出如下選項
使用el-dropdown
<el-dropdown
@command="
(command) => {
handleCommand(command, scope.$index, scope.row);
}
"
>
<el-link type="primary" :underline="false" style="margin-left: 10px"
>更多</el-link
>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="f" v-if="scope.row.active_type == 1"
><i class="el-icon-download"></i>資料下載</el-dropdown-item
>
<el-dropdown-item command="a"
><i class="el-icon-document-copy"></i>復(fù)制</el-dropdown-item
>
<el-dropdown-item command="b" v-if="scope.row.is_top == 0"
><i class="el-icon-top"></i>置頂</el-dropdown-item
>
<el-dropdown-item command="c" v-if="scope.row.is_top >= 1"
><i class="el-icon-top"></i>取消置頂</el-dropdown-item
>
<el-dropdown-item command="d"
><i class="el-icon-edit"></i>重命名</el-dropdown-item
>
<el-dropdown-item
command="e"
v-if="scope.row.active_join_num == 0"
><i class="el-icon-delete"></i>刪除</el-dropdown-item
>
</el-dropdown-menu>
</el-dropdown> <!-- 彈出的重命名-->
<el-dialog title="重命名" :visible.sync="renamePopUp" width="500px">
<el-form :model="form" label-width="70px">
<el-form-item label="新名稱:">
<el-input
placeholder="請輸入"
v-model="form.active_name"
class="d2-mr-15"
clearable
></el-input>
</el-form-item>
</el-form>
<!-- 編輯框中的確認(rèn)取消按鈕 -->
<div slot="footer" class="dialog-footer">
<el-button @click="checkClose" size="medium">取消</el-button>
<el-button
type="primary"
@click="changeData"
:loading="saveLoading"
size="medium"
>確定</el-button
>
</div>
</el-dialog> /**
* 更多
*/
handleCommand(command, index, row) {
console.log("command", command, row);
//復(fù)制
if (command == "a") {
Ajax(
{
method: "put",
url: "/active/copy",
params: { active_id: row.active_id },
},
(res) => {
this.saveLoading = false;
if (res.status_code === 200) {
this.$message({ message: "復(fù)制成功", type: "success" });
// 復(fù)制成功回到第一頁
this.pageInfo.currentPage = 1;
this.getData();
}
},
(err) => {
this.saveLoading = false;
}
);
}
//置頂
if (command == "b") {
this.handleTop(row, 1);
}
//取消置頂
if (command == "c") {
this.handleTop(row, 0);
}
// 重命名
if (command == "d") {
this.renamePopUp = true;
this.form = row;
this.editPostUrl = 3;
}
//刪除
if (command == "e") {
this.handleDelete(index, row);
}
//資料下載
if (command == "f") {
window.open(row.url_arr[0]);
}
}, /**
* 置頂
*/
handleTop(row, is_top) {
this.loading = true;
console.log(row.is_top);
Ajax(
{
url: "/active/top", // 路徑
method: "put",
params: { active_id: row.active_id, is_top: is_top },
},
(res) => {
this.loading = false;
if (res.status_code === 200) {
this.$message({ message: "操作成功", type: "success" });
this.getData();
}
},
(err) => {
this.loading = false;
}
);
}, /**
* 刪除
*/
handleDelete(index, row) {
this.$confirm("你是否確認(rèn)刪除這個活動?", "提示", {
confirmButtonText: "確定",
cancelButtonText: "取消",
type: "error",
})
.then(() => {
this.loading = true;
//刪除
Ajax(
{
method: "delete",
url: "/active",
params: { active_id: row.active_id },
},
(res) => {
this.loading = false;
if (res.status_code === 200) {
this.$message({ message: "刪除活動成功", type: "success" });
this.getData();
}
},
(err) => {
this.loading = false;
}
);
})
.catch(() => {
this.$message({ type: "info", message: "已取消刪除" });
});
},vue el-dropdown點(diǎn)擊事件
vue el-dropdown點(diǎn)擊事件有個神坑,@click不起效,要在后面加 @click.native才能生效
如下
? ? ? ? <el-dropdown-menu slot="dropdown"> ? ? ? ? ? ? ? ? ? <el-dropdown-item v-print="'#printTest'">打印</el-dropdown-item> ? ? ? ? ? ? ? ? ? <el-dropdown-item @click.native="clickGeneratePicture">圖片另存為</el-dropdown-item> ? ? ? ? ? ? ? ? ? <el-dropdown-item @click.native="lookFrish">刷新</el-dropdown-item> ? ? ? ? ? ? ? ? </el-dropdown-menu> ```</el-dropdown>
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
您可能感興趣的文章:
相關(guān)文章
一個Java程序猿眼中的前后端分離以及Vue.js入門(推薦)
這篇文章主要介紹了前后端分離及Vue.js入門,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-04-04
vue2移動端使用vue-qrcode-reader實現(xiàn)掃一掃功能的步驟
最近在使用vue開發(fā)的h5移動端想要實現(xiàn)一個調(diào)用攝像頭掃描二維碼的功能,所以下面這篇文章主要給大家介紹了關(guān)于vue2移動端使用vue-qrcode-reader實現(xiàn)掃一掃功能的相關(guān)資料,需要的朋友可以參考下2023-06-06
electron-vue開發(fā)環(huán)境內(nèi)存泄漏問題匯總
這篇文章主要介紹了electron-vue開發(fā)環(huán)境內(nèi)存泄漏問題匯總,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10

