Element MessageBox弹框的具体使用


Posted in Javascript onJuly 27, 2020

组件—弹框

消息提示

Element MessageBox弹框的具体使用

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>

确认消息

Element MessageBox弹框的具体使用

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>

提交内容

Element MessageBox弹框的具体使用

Element MessageBox弹框的具体使用

<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>

自定义

Element MessageBox弹框的具体使用

Element MessageBox弹框的具体使用

<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 = '执行中...';
       setTimeout(() => {
        done();
        setTimeout(() => {
         instance.confirmButtonLoading = false;
        }, 300);
       }, 3000);
      } else {
       done();
      }
     }
    }).then(action => {
     this.$message({
      type: 'info',
      message: 'action: ' + action
     });
    });
   }
  }
 }
</script>

使用 HTML 片段

Element MessageBox弹框的具体使用

Element MessageBox弹框的具体使用

<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>

区分取消与关闭

Element MessageBox弹框的具体使用

Element MessageBox弹框的具体使用

<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>

居中布局

Element MessageBox弹框的具体使用

Element MessageBox弹框的具体使用

<template>
 <el-button type="text" @click="open">点击打开 Message Box</el-button>
</template>

<script>
 export default {
  methods: {
   open() {
    this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
     confirmButtonText: '确定',
     cancelButtonText: '取消',
     type: 'warning',
     center: true
    }).then(() => {
     this.$message({
      type: 'success',
      message: '删除成功!'
     });
    }).catch(() => {
     this.$message({
      type: 'info',
      message: '已取消删除'
     });
    });
   }
  }
 }
</script>

全局方法

Element MessageBox弹框的具体使用

单独引用

Element MessageBox弹框的具体使用

Options

Element MessageBox弹框的具体使用

Element MessageBox弹框的具体使用

Element MessageBox弹框的具体使用

Element MessageBox弹框的具体使用

到此这篇关于Element MessageBox弹框的具体使用的文章就介绍到这了,更多相关Element MessageBox弹框内容请搜索三水点靠木以前的文章或继续浏览下面的相关文章希望大家以后多多支持三水点靠木!

Javascript 相关文章推荐
bcastr2.0 通用的图片浏览器
Nov 22 Javascript
jQuery学习总结之jQuery事件
Jun 30 Javascript
JavaScript语言对Unicode字符集的支持详解
Dec 30 Javascript
jfreechart插件将数据展示成饼状图、柱状图和折线图
Apr 13 Javascript
原生js实现倒计时功能(多种格式调用)
Jan 12 Javascript
原生js实现旋转木马轮播图效果
Feb 27 Javascript
jQuery插件HighCharts绘制简单2D柱状图效果示例【附demo源码】
Mar 21 jQuery
js操作table中tr的顺序实现上移下移一行的效果
Nov 22 Javascript
node中使用log4js4.x版本记录日志的方法
Aug 20 Javascript
如何在微信小程序中使用骨架屏的步骤
Jun 12 Javascript
axios封装与传参示例详解
Oct 18 Javascript
jQuery冲突问题解决方法
Jan 19 jQuery
Vue 组件复用多次自定义参数操作
Jul 27 #Javascript
使用Element的InfiniteScroll 无限滚动组件报错的解决
Jul 27 #Javascript
Element InfiniteScroll无限滚动的具体使用方法
Jul 27 #Javascript
vue中父子组件传值,解决钩子函数mounted只运行一次的操作
Jul 27 #Javascript
Element Alert警告的具体使用方法
Jul 27 #Javascript
Element Badge标记的使用方法
Jul 27 #Javascript
谈一谈vue请求数据放在created好还是mounted里好
Jul 27 #Javascript
You might like
php数组合并与拆分实例分析
2015/06/12 PHP
简单介绍win7下搭建apache+php+mysql开发环境
2015/08/06 PHP
php in_array() 检查数组中是否存在某个值详解
2016/11/23 PHP
yii2利用自带UploadedFile实现上传图片的示例
2017/02/16 PHP
PHP设计模式(四)原型模式Prototype实例详解【创建型】
2020/05/02 PHP
把jquery 的dialog和ztree结合实现步骤
2013/08/02 Javascript
jquery实现下拉菜单的二级联动利用json对象从DB取值显示联动
2014/03/27 Javascript
详解Javascript动态操作CSS
2014/12/08 Javascript
BootStrap框架个人总结(bootstrap框架、导航条、下拉菜单、轮播广告carousel、栅格系统布局、标签页tabs、模态框、菜单定位)
2016/12/01 Javascript
JS实现给对象动态添加属性的方法
2017/01/05 Javascript
vue-dialog的弹出层组件
2020/05/25 Javascript
使用openSpeDiv方法实现Ecshop登录弹窗框效果
2017/03/13 Javascript
在knockoutjs 上自己实现的flux(实例讲解)
2017/12/18 Javascript
Vue指令实现OutClick的示例
2020/11/16 Javascript
Python 40行代码实现人脸识别功能
2017/04/02 Python
python字符串过滤性能比较5种方法
2017/06/22 Python
Python使用pyh生成HTML文档的方法示例
2018/03/10 Python
Python实现决策树C4.5算法的示例
2018/05/30 Python
pytorch中tensor的合并与截取方法
2018/07/26 Python
Python3实现取图片中特定的像素替换指定的颜色示例
2019/01/24 Python
python可视化实现KNN算法
2019/10/16 Python
Python with标签使用方法解析
2020/01/17 Python
python小白切忌乱用表达式
2020/05/29 Python
python中tab键是什么意思
2020/06/18 Python
python可以用哪些数据库
2020/06/22 Python
python request 模块详细介绍
2020/11/10 Python
使用HTML5在网页中嵌入音频和视频播放的基本方法
2016/02/22 HTML / CSS
以实惠的价格提供高品质的时尚:Newchic
2018/01/18 全球购物
英国时尚优质的女装:Hope Fashion
2018/08/14 全球购物
应届生新闻编辑求职信
2013/11/19 职场文书
一份报关员的职业规划范文
2014/01/08 职场文书
数学教学随笔感言
2014/02/17 职场文书
无财产离婚协议书范本
2014/10/28 职场文书
初中作文评语集锦
2014/12/25 职场文书
2016年敬老月活动总结
2016/04/05 职场文书
Nginx文件已经存在全局反向代理问题排查记录
2022/07/15 Servers