# 预览

关闭

# 案例

<template>
  <div>
    <b-switch
      v-model="switchVal"
      openText=""
      closeText=""
      :defaultChecked="true"
      @clickSwitch="clickSwitch"
      @changeSwitch="changeSwitch"
    >
      <template slot="openSlot">
        <b>开启</b>
      </template>
      <span slot="closeSlot">关闭</span>
    </b-switch>
  </div>
</template>

<script>
export default {
  data() {
    return {
      switchVal: false,
    };
  },
  methods: {
    clickSwitch(a, b) {
      console.log(a, b);
    },
    changeSwitch(a) {
      console.log(a);
    },
  },
};
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

# API

参数 说明 类型 默认值
visible 是否显示对话框,可使用 v-model 双向绑定数据。 Boolean false
title 对话框标题 String 标题
cancelText 取消按钮文字 String 取消
confirmText 确定按钮文字 String 确定
mask 是否显示遮罩层 Boolean true
maskClosable 点击遮罩层是否关闭对话框 Boolean true

# 事件

参数 说明 返回值
on-cancel 点击取消按钮回调
on-confirm 点击确认按钮回调
on-close 点击右上角关闭按钮回调
visible-change 显示状态发生变化时触发 true/false

# 插槽

名称 说明
foot 自定义页脚内容