Element MessageBox彈框的具體使用
更新時間:2020年07月27日 10:13:44 作者:ForeverJPB.
這篇文章主要介紹了Element MessageBox彈框的具體使用,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
組件—彈框
消息提示
<template> <el-button type="text" @click="open">點擊打開 Message Box</el-button> </template> <script> export default { methods: { open() { this.$alert('這是一段內容', '標題名稱', { confirmButtonText: '確定', callback: action => { this.$message({ type: 'info', message: `action: ${ action }` }); } }); } } } </script>
確認消息
<template> <el-button type="text" @click="open">點擊打開 Message Box</el-button> </template> <script> export default { methods: { open() { this.$alert('這是一段內容', '標題名稱', { confirmButtonText: '確定', callback: action => { this.$message({ type: 'info', message: `action: ${ action }` }); } }); } } } </script>
提交內容
<template> <el-button type="text" @click="open">點擊打開 Message Box</el-button> </template> <script> export default { methods: { open() { this.$prompt('請輸入郵箱', '提示', { confirmButtonText: '確定', cancelButtonText: '取消', inputPattern: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/, inputErrorMessage: '郵箱格式不正確' }).then(({ value }) => { this.$message({ type: 'success', message: '你的郵箱是: ' + value }); }).catch(() => { this.$message({ type: 'info', message: '取消輸入' }); }); } } } </script>
自定義
<template> <el-button type="text" @click="open">點擊打開 Message Box</el-button> </template> <script> export default { methods: { open() { const h = this.$createElement; this.$msgbox({ title: '消息', message: h('p', null, [ h('span', null, '內容可以是 '), h('i', { style: 'color: teal' }, 'VNode') ]), showCancelButton: true, confirmButtonText: '確定', cancelButtonText: '取消', beforeClose: (action, instance, done) => { if (action === 'confirm') { instance.confirmButtonLoading = true; instance.confirmButtonText = '執(zhí)行中...'; setTimeout(() => { done(); setTimeout(() => { instance.confirmButtonLoading = false; }, 300); }, 3000); } else { done(); } } }).then(action => { this.$message({ type: 'info', message: 'action: ' + action }); }); } } } </script>
使用 HTML 片段
<template> <el-button type="text" @click="open">點擊打開 Message Box</el-button> </template> <script> export default { methods: { open() { this.$alert('<strong>這是 <i>HTML</i> 片段</strong>', 'HTML 片段', { dangerouslyUseHTMLString: true }); } } } </script>
區(qū)分取消與關閉
<template> <el-button type="text" @click="open">點擊打開 Message Box</el-button> </template> <script> export default { methods: { open() { this.$alert('<strong>這是 <i>HTML</i> 片段</strong>', 'HTML 片段', { dangerouslyUseHTMLString: true }); } } } </script>
居中布局
<template> <el-button type="text" @click="open">點擊打開 Message Box</el-button> </template> <script> export default { methods: { open() { this.$confirm('此操作將永久刪除該文件, 是否繼續(xù)?', '提示', { confirmButtonText: '確定', cancelButtonText: '取消', type: 'warning', center: true }).then(() => { this.$message({ type: 'success', message: '刪除成功!' }); }).catch(() => { this.$message({ type: 'info', message: '已取消刪除' }); }); } } } </script>
全局方法
單獨引用
Options
到此這篇關于Element MessageBox彈框的具體使用的文章就介紹到這了,更多相關Element MessageBox彈框內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
vue2.0 移動端實現(xiàn)下拉刷新和上拉加載更多的示例
本篇文章主要介紹vue2.0 移動端實現(xiàn)下拉刷新和上拉加載更多的示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-04-04解讀element?el-upload上傳的附件名稱不顯示?file-list賦值
這篇文章主要介紹了解讀element?el-upload上傳的附件名稱不顯示?file-list賦值問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-10-10Vue項目總結之webpack常規(guī)打包優(yōu)化方案
這篇文章主要介紹了vue項目總結之webpack常規(guī)打包優(yōu)化方案,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-06-06