element中的$confirm的使用
可以諸如此類的封裝一下
/*
* 公用提示窗
* @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)要刪除嗎")
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 = ['是否將此項移除?', '注意:移除后不可恢復(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)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
JavaScript實現(xiàn)動態(tài)增刪表格的方法
本篇文章主要介紹了JavaScript實現(xiàn)動態(tài)增刪表格,可以實現(xiàn)表格增加和刪除數(shù)據(jù)的功能,非常具有實用價值,有興趣的可以了解一下2017-03-03
如何將網(wǎng)頁表格內(nèi)容導(dǎo)入excel
這篇文章主要介紹了如何將網(wǎng)頁表格內(nèi)容導(dǎo)入excel,需要的朋友可以參考下2014-02-02
LayUi中接口傳數(shù)據(jù)成功,表格不顯示數(shù)據(jù)的解決方法
今天小編就為大家分享一篇LayUi中接口傳數(shù)據(jù)成功,表格不顯示數(shù)據(jù)的解決方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-08-08
element-ui組件輸入框之放大鏡搜索圖標(biāo)問題
這篇文章主要介紹了element-ui組件輸入框之放大鏡(搜索圖標(biāo))的相關(guān)知識,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-11-11
JavaScript實現(xiàn)選中文字提示新浪微博分享效果
這篇文章主要為大家詳細(xì)介紹了JavaScript實現(xiàn)選中文字提示新浪微博分享效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-06-06
如何在JavaScript中實現(xiàn)私有屬性的寫類方式(二)
這篇文章主要介紹了如何在JavaScript中實現(xiàn)私有屬性的寫類方式。需要的朋友可以過來參考下,希望對大家有所幫助2013-12-12
JS實現(xiàn)在網(wǎng)頁中彈出一個輸入框的方法
這篇文章主要介紹了JS實現(xiàn)在網(wǎng)頁中彈出一個輸入框的方法,實例分析了prompt的用法,可用來設(shè)置密碼,具有一定參考借鑒價值,需要的朋友可以參考下2015-03-03

