element中的$confirm的使用
更新時間:2020年04月26日 10:35:08 作者:yang
這篇文章主要介紹了element中的$confirm的使用,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
可以諸如此類的封裝一下
/* * 公用提示窗 * @export * @param {string}[desc="確認操作"]彈框提示文字 * @param {string}[title="提示"]彈框標題 * @param{string}[confirmButtonName ='確認']確認按鈕文字 * @param {string}[cancelButtonName="取消"] 取消按鈕文字 * @param{boolean}[distinguishCancelAndClose = false]關(guān)系和取消是否執(zhí)行同一方法 *@return * */ export function confirm (desc = '確認操作', title = '提示', confirmButtonName = '確認', 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,"確認要刪除嗎") 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中apply和call以及bind(推薦)
在javascript中apply、call和bind是三兄弟,很好的搭檔,下面小編給大家全面解析JavaScript中apply和call以及bind的相關(guān)知識,感興趣的朋友一起學(xué)習(xí)吧2016-06-06