element中的$confirm的使用
更新時(shí)間:2020年04月26日 10:35:08 作者:yang
這篇文章主要介紹了element中的$confirm的使用,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
可以諸如此類的封裝一下
/*
* 公用提示窗
* @export
* @param {string}[desc="確認(rèn)操作"]彈框提示文字
* @param {string}[title="提示"]彈框標(biāo)題
* @param{string}[confirmButtonName ='確認(rèn)']確認(rèn)按鈕文字
* @param {string}[cancelButtonName="取消"] 取消按鈕文字
* @param{boolean}[distinguishCancelAndClose = false]關(guān)系和取消是否執(zhí)行同一方法
*@return
*
*/
export function confirm (desc = '確認(rèn)操作', title = '提示', confirmButtonName = '確認(rèn)', cancelButtonName = '取消', distinguishCancelAndClose = false) {
return this.$confirm(desc, title, {
confirmButtonName: confirmButtonName,
cancelButtonName: cancelButtonName,
distinguishCancelAndClose: distinguishCancelAndClose,
closeOnClickModel: false,
type: 'warning',
center: true
})
}
xxx//vue
submitSome(){
try(){
async utils.confirm.call(this,"確認(rèn)要?jiǎng)h除嗎")
const formData = {
'id':this.id
}
let res = await this.$post('/sss',formData)
if(res.code===1){
//do something
}
}catch(e){
console.log(e)
// 如果需要關(guān)閉和取消有所區(qū)別
if(e==='close'){
//do something
}else if(e==='cancel'){
//do something
}
}
}
this.$confirm確定框內(nèi)容換行顯示
// 把寫的提示信心需要換行的地方分成數(shù)組 confirmText
const confirmText = ['是否將此項(xiàng)移除?', '注意:移除后不可恢復(fù)。']
const newDatas = []
const h = this.$createElement
for (const i in confirmText) {
newDatas.push(h('p', null, confirmText[i]))
}
this.$confirm(
'提示',
{
title: '提示',
message: h('div', null, newDatas),
showCancelButton: true,
confirmButtonText: '確定',
cancelButtonText: '取消',
type: 'warning'
} ).then(() => { })
到此這篇關(guān)于element中的$confirm的使用的文章就介紹到這了,更多相關(guān)element $confirm 內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
原生js實(shí)現(xiàn)寬度計(jì)數(shù)器
這篇文章主要為大家詳細(xì)介紹了原生js實(shí)現(xiàn)寬度計(jì)數(shù)器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-09-09
微信小程序簡潔登錄頁面的實(shí)現(xiàn)(附源碼)
本文主要介紹了微信小程序簡潔登錄頁面的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-12-12
全面解析JavaScript中apply和call以及bind(推薦)
在javascript中apply、call和bind是三兄弟,很好的搭檔,下面小編給大家全面解析JavaScript中apply和call以及bind的相關(guān)知識(shí),感興趣的朋友一起學(xué)習(xí)吧2016-06-06
layer子層給父層頁面元素賦值,以達(dá)到向父層頁面?zhèn)髦档男Ч麑?shí)例
下面小編就為大家?guī)硪黄猯ayer子層給父層頁面元素賦值,以達(dá)到向父層頁面?zhèn)髦档男Ч麑?shí)例。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-09-09

