WinDesign WinDesign
首页
设计语言
基础组件
图表规范
主题方案
资源下载
Pro(Admin)
v2-0-0
  • v2-0-0
  • v1-7-9
  • v1-7-8
  • v1-7-7
  • v1-7-6
  • v1-7-5
  • v1-7-4
  • v1-7-3
  • v1-7-2
  • v1-7-16
  • v1-7-15
  • v1-7-14
  • v1-7-13
  • v1-7-11
  • v1-7-10
  • v1-7-1
  • v1-7-0
  • v1-6-7
  • v1-6-6
  • v1-6-5
  • v1-6-4
  • v1-6-3
  • v1-6-2
  • v1-6-1
  • v1-6-0
  • v1-5-9
  • v1-5-8
  • v1-5-7
  • v1-5-6
  • v1-5-5
  • v1-5-4
  • v1-5-3
  • v1-5-25
  • v1-5-24
  • v1-5-23
  • v1-5-22
  • v1-5-21
  • v1-5-20
  • v1-5-2
  • v1-5-19
  • v1-5-18
  • v1-5-17
  • v1-5-16
  • v1-5-15
  • v1-5-14
  • v1-5-12
  • v1-5-11
  • v1-5-10
  • v1-5-1
  • v1-5-0
首页
设计语言
基础组件
图表规范
主题方案
资源下载
Pro(Admin)
v2-0-0
  • v2-0-0
  • v1-7-9
  • v1-7-8
  • v1-7-7
  • v1-7-6
  • v1-7-5
  • v1-7-4
  • v1-7-3
  • v1-7-2
  • v1-7-16
  • v1-7-15
  • v1-7-14
  • v1-7-13
  • v1-7-11
  • v1-7-10
  • v1-7-1
  • v1-7-0
  • v1-6-7
  • v1-6-6
  • v1-6-5
  • v1-6-4
  • v1-6-3
  • v1-6-2
  • v1-6-1
  • v1-6-0
  • v1-5-9
  • v1-5-8
  • v1-5-7
  • v1-5-6
  • v1-5-5
  • v1-5-4
  • v1-5-3
  • v1-5-25
  • v1-5-24
  • v1-5-23
  • v1-5-22
  • v1-5-21
  • v1-5-20
  • v1-5-2
  • v1-5-19
  • v1-5-18
  • v1-5-17
  • v1-5-16
  • v1-5-15
  • v1-5-14
  • v1-5-12
  • v1-5-11
  • v1-5-10
  • v1-5-1
  • v1-5-0
  • 开始

    • 介绍
    • 快速上手
    • 主题定制
    • 更新日志
  • Basic

    • Color 色彩
    • Box 盒子
    • Typography 字体
  • 通用

    • Avatar 头像
    • Button 按钮
    • Icon 通用图标
    • Iconx 业务图标
    • Layout 布局
  • 导航

    • Affix 固钉
    • Breadcrumb 面包屑
    • Dropdown 下拉菜单
    • Menu 菜单
    • Pagination 分页
    • Steps 步骤条
  • 数据录入

    • Checkbox 多选框
    • Cascader 级联选择器
    • Color-picker 颜色选择器
    • Date-picker 日期选择器
    • Date-time-picker 日期时间选择器
    • Form 表单
    • Input 输入框
    • Input-number 数字输入框
    • Radio 单选按钮
    • Rate 评分
    • Select 选择器
    • Switch 开关
    • Slider 滑块
    • Tree-select 选择器
    • Time-picker 时间选择器
    • Transfer 穿梭框
    • Upload 上传
  • 数据展示

    • Badge 徽标
    • Progress 进度条
    • Popover 弹出框
    • Status 状态
    • Table 表格
    • Tabs 标签页
    • Tag 标签
    • Timeline 时间轴
    • Tooltip 文字提示
    • Tree 树
  • 反馈

    • Alert 警告
    • Drawer 抽屉
    • Loading 加载
    • Message 全局提示
    • MessageBox 弹框
    • Modal 对话框
      • Notification 通知
      • Popconfirm 气泡确认框
      • Skeleton 骨架屏
    • 其他

      • Anchor 锚点
      • BackTop 回到顶部
      • Card 卡片
      • Collapse 折叠面板
      • Carousel 走马灯
      • Calendar 日历
      • Infinite-scroll 无限滚动
      • Title 标题
    • 迁移

      • 从WinDesign 1.x迁移

    # Modal 对话框

    # 代码演示

    Modal基础用法 副标题

    基础用法

    before-close-modal,before-close-button,before-close分别在点击遮罩层,关闭图标和全部时起效

    查看代码

    <template>
      <w-button type="text" @click="visible = !visible">点击打开Modal</w-button>
      <w-modal
        :visible.sync="visible"
        :title="title"
        :before-close-modal="handleCloseModal"
        subtitle="副标题"
        width="30%"
      >
        <span>这是一段信息</span>
        <span slot="footer" class="dialog-footer">
          <w-button @click="visible = false">取 消</w-button>
          <w-button
            style="margin-left: 15px"
            type="primary"
            @click="visible = false"
          >
            确 定
          </w-button>
        </span>
      </w-modal>
    </template>
    <script>
      export default {
        data() {
          return {
            visible: false,
          }
        },
        methods: {
          handleCloseModal(done) {
            this.$Confirm('确认关闭Modal?')
              .then(_ => {
                done();
              })
              .catch(_ => {});
          }
        }
      }
    </script>
    彩色样式的Modal

    彩色样式

    需要使用 color 属性可以为Modal添加色彩。

    查看代码

    <template>
      <w-button @click="visible = !visible">彩色样式的Modal</w-button>
      <w-modal  :visible.sync="visible"
        color
        :title="title"
        width="30%">
        <span>这是一段信息</span>
        <span slot="footer" class="dialog-footer">
        <w-button @click="visible = false">取 消</w-button>
        <w-button type="primary" @click="visible = false">确 定</w-button>
        </span>
      </w-modal>
    </template>
    异步关闭

    异步关闭

    点击确定,查看异步关闭效果。

    查看代码

    <template>
      <w-button @click="visible = !visible">点击打开 Modal</w-button>
      <w-modal  :visible.sync="visible"
        :title="title"
        width="30%">
        <span>这是一段信息</span>
        <span slot="footer" class="dialog-footer">
          <w-button :icon="loadingIcon" @click="showModal()">取 消</w-button>
          <w-button type="primary" :icon="loadingIcon" @click="showModal()">确 定</w-button>
        </span>
      </w-modal>
    </template>
    <script>
    export default {
      data () {
        return {
          visible: false,
          isIcon: '',
          title:'异步关闭',
          showClose: false
         }
        },
      computed:{
        loadingIcon:function(){
          return this.isIcon ? 'w-icon-loading' : ''
        }
      },
      methods: {
        showModal (val) {
          this.isIcon = true
          let _this= this
          setTimeout(function()  {
            _this.visible = false
            _this.isIcon = false
          }, 1500)
        }
      }
    }
    </script>
    打开嵌套树的Modal

    自定义内容

    Modal 组件的内容可以是任意的,甚至可以是表格或表单,下面是应用了 tree 组件的样例。

    查看代码

    <template>
      <w-button @click="visible = !visible">打开嵌套树的Modal</w-button>
      <w-modal :visible.sync="visible"
        :title="title"
        width="30%">
        <w-tree :data="data" :props="defaultProps"></w-tree>
        <span slot="footer" class="dialog-footer">
          <w-button @click="visible = false">取 消</w-button>
          <w-button type="primary" @click="visible = false">确 定</w-button>
        </span>
      </w-modal>
    </template>
    <script>
      export default {
        data () {
          return {
             data: [
              {
                label: '一级 1',
                children: [{
                  label: '二级 1-1',
                  children: [{
                    label: '三级 1-1-1'
                  }]
                }]
              }, {
                label: '一级 2',
                children: [{
                  label: '二级 2-1',
                  children: [{
                    label: '三级 2-1-1'
                  }]
                }, {
                  label: '二级 2-2',
                  children: [{
                    label: '三级 2-2-1'
                  }]
                }]
              }, {
                label: '一级 3',
                children: [{
                  label: '二级 3-1',
                  children: [{
                    label: '三级 3-1-1'
                  }]
                }, {
                  label: '二级 3-2',
                  children: [{
                    label: '三级 3-2-1'
                  }]
                }]
              }],
            defaultProps: {
              children: 'children',
              label: 'label'
            }
          }
        }
        }
    </script>
    外层 Modal

    嵌套Modal

    正常情况下,我们不建议使用嵌套的 Modal,如果需要在页面上同时显示多个 Modal,可以将它们平级放置。对于确实需要嵌套 Modal 的场景,我们提供了append-to-body属性。将内层 Modal 的该属性设置为 true,它就会插入至 body 元素上,从而保证内外层 Modal 和遮罩层级关系的正确。

    查看代码

    <template>
      <section class="pagination-demo">
          description="正常情况下,我们不建议使用嵌套的 Modal,如果需要在页面上同时显示多个 Modal,可以将它们平级放置。对于确实需要嵌套 Modal 的场景,我们提供了append-to-body属性。将内层 Modal 的该属性设置为 true,它就会插入至 body 元素上,从而保证内外层 Modal 和遮罩层级关系的正确。">
          <w-button type='text'
                    @click="outerVisible = true">点击打开外层 Modal</w-button>
          <w-modal  :visible.sync="outerVisible"
                    width="60%"
                    color
                    title="外层 Modal"
                    >
            <w-modal
              width="30%"
              title="内层 Modal"
              :visible.sync="innerVisible"
              append-to-body>
            </w-modal>
            <span slot="footer" class="dialog-footer">
                <w-button @click="outerVisible = false">取 消</w-button>
                <w-button style="margin-left: 15px;" type="primary" @click="innerVisible = true">点击打开内层 Modal</w-button>
              </span>
          </w-modal>
      </section>
    </template>
    
    居中布局

    居中布局

    标题和底部可水平居中。

    查看代码

    <template>
      <w-button @click="visible = !visible">点击打开Modal</w-button>
      <w-modal  :visible.sync="visible"
        center
        :title="title"
        width="30%">
        <span>这是一段信息</span>
        <span slot="footer" class="dialog-footer">
          <w-button @click="visible = false">取 消</w-button>
          <w-button type="primary" @click="visible = false">确 定</w-button>
        </span>
      </w-modal>
    </template>

    # API

    # Attributes

    参数 说明 类型 可选值 默认值 Version
    append-to-body Modal 自身是否插入至 body 元素上。嵌套的 Modal 必须指定该属性并赋值为 true Boolean — false
    before-close 关闭前的回调,会暂停 Modal 的关闭 Function(done),done 用于关闭 Modal — —
    before-close-modal 点击遮罩层关闭前的回调,会暂停 Modal 的关闭,使用before-close,此方法失效 Function(done),done 用于关闭 Modal — —
    before-close-button 点击关闭icon关闭前的回调,会暂停 Modal 的关闭,使用before-close,此方法失效 Function(done),done 用于关闭 Modal — —
    center 是否对头部和底部采用居中布局 Boolean — false
    custom-class Modal 的自定义类名 String — —
    close-on-click-modal 是否可以通过点击遮罩 关闭 Modal Boolean — true
    close-on-press-escape 是否可以通过按下 ESC 关闭 Modal Boolean — true
    fullscreen 是否为全屏 Modal Boolean — false
    lock-scroll 是否在 Modal 出现时将 body 滚动锁定 Boolean — true
    modal 是否显示遮罩, 默认显示 Boolean — true
    modal-append-to-body 遮罩层是否插入至 body 元素上,若为 false,则遮罩层会插入至 Modal 的父元素上 Boolean — true
    title Modal 的标题,也可通过具名 slot (见下表)传入 String — —
    top Modal CSS 中的 margin-top 值 String — 20vh
    show-close 是否显示关闭按钮 Boolean — true
    subtitle 副标题 String — — v2.0.0
    visible 是否显示 Modal,支持 .sync 修饰符 Boolean — true
    width Modal 的宽度 String — 50%

    # Slot

    名称 说明 Version
    — Modal 的内容
    footer Modal 按钮操作区的内容
    title Modal 标题区的内容

    # Events

    事件名称 说明 回调参数 Version
    close Modal 关闭的回调 —
    closed Modal 关闭动画结束时的回调 —
    open Modal 打开的回调 —
    opened Modal 打开动画结束时的回调 —

    # 贡献者

    类型 参与者
    设计者 UED视觉组
    维护者 UED前端组
    上次更新: 8/11/2021, 5:58:17 PM

    ← MessageBox 弹框 Notification 通知 →