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 相关文章推荐
jQuery使用手册之 事件处理
Mar 24 Javascript
初窥JQuery(二)事件机制(2)
Dec 06 Javascript
如何确保JavaScript的执行顺序 之jQuery.html深度分析
Mar 03 Javascript
JavaScript中return false的用法
Mar 12 Javascript
jQuery制作可自定义大小的拼图游戏
Mar 30 Javascript
基于javascript制作微博发布栏效果
Apr 04 Javascript
Jquery获取第一个子元素简单实例
Jun 02 Javascript
Vue.js每天必学之内部响应式原理探究
Sep 07 Javascript
最实用的jQuery分页插件
Oct 09 Javascript
Ajax请求时无法重定向的问题解决代码详解
Jun 21 Javascript
Servlet返回的数据js解析2种方法
Dec 12 Javascript
VUE使用draggable实现组件拖拽
Apr 06 Vue.js
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 set_time_limit(0)长连接的实现分析
2010/03/02 PHP
PHP中10个不常见却非常有用的函数
2010/03/21 PHP
php实现用户在线时间统计详解
2011/10/08 PHP
Symfony2安装第三方Bundles实例详解
2016/02/04 PHP
FleaPHP框架数据库查询条件($conditions)写法总结
2016/03/19 PHP
Laravel5.1 框架控制器基础用法实例分析
2020/01/04 PHP
推荐25个超炫的jQuery网格插件
2014/11/28 Javascript
轻松创建nodejs服务器(9):实现非阻塞操作
2014/12/18 NodeJs
使用javascript实现监控视频播放并打印日志
2015/01/05 Javascript
深入理解JavaScript系列(18):面向对象编程之ECMAScript实现
2015/03/05 Javascript
浅谈js中的闭包
2015/03/16 Javascript
深入分析Javascript跨域问题
2015/04/17 Javascript
可以浮动某个物体的jquery控件用法实例
2015/07/24 Javascript
JS面试题---关于算法台阶的问题
2016/07/26 Javascript
基于daterangepicker日历插件使用参数注意的问题
2017/08/10 Javascript
javascript+jQuery实现360开机时间显示效果
2017/11/03 jQuery
JavaScript中关于class的调用方法
2017/11/28 Javascript
详解Vue中组件的缓存
2019/04/20 Javascript
Vue+Bootstrap实现简易学生管理系统
2021/02/09 Vue.js
[10:14]2018DOTA2国际邀请赛寻真——paiN Gaming不仅为自己而战
2018/08/14 DOTA
python使用__slots__让你的代码更加节省内存
2018/09/05 Python
python实现切割url得到域名、协议、主机名等各个字段的例子
2019/07/25 Python
通过selenium抓取某东的TT购买记录并分析趋势过程解析
2019/08/15 Python
HTML5拍照和摄像机功能实战详解
2019/01/24 HTML / CSS
我有一个char * 型指针正巧指向一些int 型变量, 我想跳过它们。 为什么如下的代码((int *)p)++; 不行?
2013/05/09 面试题
高中生毕业学习总结的自我评价
2013/11/14 职场文书
小学教育毕业生自荐信
2013/11/18 职场文书
《长江之歌》教学反思
2014/04/17 职场文书
大学开学计划书
2014/04/30 职场文书
根叔历年演讲稿
2014/05/20 职场文书
求职信标题怎么写
2014/05/26 职场文书
暑假安全保证书
2015/02/28 职场文书
销售员自我评价
2015/03/11 职场文书
2015年高校就业工作总结
2015/05/04 职场文书
Java面试题冲刺第十八天--Spring框架3
2021/08/07 面试题
浅谈 JavaScript 沙箱Sandbox
2021/11/02 Javascript