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

點擊【更多】彈出如下選項
使用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點擊事件
vue el-dropdown點擊事件有個神坑,@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)文章
vue 項目中的this.$get,this.$post等$的用法案例詳解
vue.js的插件應(yīng)該暴露一個install方法。這個方法的第一個參數(shù)是vue構(gòu)造器,第二個參數(shù)是一個可選的選項對象,首頁要安裝axios,本文結(jié)合案例代碼給大家詳細(xì)講解vue 中的this.$get,this.$post等$的用法,一起學(xué)習(xí)下吧2022-12-12
Vue實現(xiàn)當(dāng)前頁面刷新的4種方法舉例
我們在開發(fā)vue的頁面的時候,有時候會遇到需要刷新當(dāng)前頁面功能,但是vue框架自帶的router是不支持刷新當(dāng)前頁面功能,下面這篇文章主要給大家介紹了關(guān)于Vue實現(xiàn)當(dāng)前頁面刷新的4種方法,需要的朋友可以參考下2023-04-04

