项目作者: baixiuyue

项目描述 :
基于Bootstrap V4的模态弹窗
高级语言: JavaScript
项目地址: git://github.com/baixiuyue/vue-bai-modal.git
创建时间: 2018-04-23T08:22:27Z
项目社区:https://github.com/baixiuyue/vue-bai-modal

开源协议:

下载


基于Bootstrap V4的模态弹窗

使用方法

  1. import Vue from 'vue';
  2. import 'animate.css/animate.css';
  3. import 'bootstrap/dist/css/bootstrap.min.css';
  4. import BootstrapModal from 'vue-bai-modal';
  5. Vue.use(BootstrapModal, configs);

configs {Object} 参数说明:

  • i18nvue-i18n模块,如果需要传入参数,则该属性必须存在
  • title:对应语言配置文件中 标题 对应的路径
  • alertTitle:对应语言配置文件中 Alert弹窗的标题 对应的路径
  • ok:对应语言配置文件中 确认按钮的文本 对应的路径
  • cancel:对应语言配置文件中 取消按钮的文本 对应的路径

全局组件

  1. <template>
  2. <div>
  3. <v-modal v-model="show" @ok="show=!show">内容</v-modal>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. data(){
  9. show: false
  10. }
  11. }
  12. </script>

直接调用

  1. <template>
  2. <div>
  3. <button @click="modal">modal</button>
  4. <button @click="alert">alert</button>
  5. <button @click="confirm">confirm</button>
  6. </div>
  7. </template>
  8. <script>
  9. export default {
  10. data(){
  11. show: false
  12. },
  13. methods:{
  14. modal(){
  15. this.$modal({
  16. title: 'this is title',
  17. content: 'here is content',
  18. ok() {
  19. alert('click ok button');
  20. this.close();
  21. },
  22. cancel() {
  23. alert('click cancel button');
  24. }
  25. });
  26. },
  27. alert(){
  28. this.$modal.alert('提示信息');
  29. },
  30. confirm(){
  31. this.$modal.confirm('标题', '提示信息', function(){
  32. alert('确认');
  33. }, function(){
  34. alert('取消');
  35. });
  36. }
  37. }
  38. }
  39. </script>

参数

参数名 类型 备注
title String 标题
content String 内容
ok Function 确定回调函数,该函数返回true则会阻止关闭,需要手动调用this.close()进行关闭
okText String 确定按钮文本
cancel Function 取消回调函数,该函数返回true则会阻止关闭(this.$modal.confirm除外),需要手动调用this.close()进行关闭
cancelText String 取消文牛的文本
mask Boolean 是否显示遮罩层。true显示,false不显示
size String 显示窗口的尺寸。默认为空字符串,可选参数有:sm, lg

直接调用方法

  1. this.$modal(options)
  1. this.$modal.alert(content, cancelFn)
  1. this.$modal.confirm(title, content, okFn, cancelFn)

示例

执行npm run dev可查看demo。示例代码位于demo文件夹