iview-mpvue
  • 首页
  • 布局
    • Layout 栅格布局
    • Grid 宫格
    • Panel 面板
    • List 列表
    • Card 卡片
  • 基础组件
    • Button 按钮
    • Color 色彩
    • Icon 图标
  • 导航
    • TabBar 标签栏
    • Tabs 标签页
    • Drawer 抽屉
    • Page 分页
    • Steps 步骤条
    • NoticeBar 通告栏
    • Index 索引选择器
    • Sticky 吸顶容器
  • 操作反馈
    • ActionSheet 动作面板
    • Toast 轻提示
    • Modal 对话框
    • Message 全局提醒
    • Spin 加载中
    • Swipeout 滑动菜单
  • 视图
    • Badge 徽章
    • Alert 警告提示
    • Tag 标签
    • Progress 进度条
    • Avatar 头像
    • CountDown 倒计时
    • Divider 分隔符
    • Collapse 折叠面板
    • LoadMore 页底提示
  • 表单
    • Input 输入框
    • Radio 单选
    • Checkbox 复选
    • Switch 开关
    • Rate 评分
    • InputNumber 数字输入框
Powered by GitBook
On this page
  • 概述
  • 使用指南
  • 示例
  • API

Was this helpful?

  1. 表单

Switch 开关

概述

在两种状态间切换时用到的开关选择器。

使用指南

在.vue中引入组件

<script>
    import iSwitch from 'iview-mpvue/dist/components/switch/switch'
    export default {
        components: {
            'i-switch': iSwitch
        }
    }
</script>

示例

<i-cell-group>
    <i-cell title="基本用法">
        <i-switch :value="switch1" @change="onChange" slot="footer"></i-switch>
    </i-cell>
    <i-cell title="自定义内容">
        <i-switch :value="switch1" size="large" @change="onChange" slot="footer">
            <view slot="open">开启</view>
            <view slot="close">关闭</view>
        </i-switch>
    </i-cell>
    <i-cell title="图标">
        <i-switch :value="switch1" @change="onChange" slot="footer">
            <i-icon type="right" slot="open"></i-icon>
            <i-icon type="close" slot="close"></i-icon>
        </i-switch>
    </i-cell>
    <i-cell title="禁止切换">
        <i-switch :value="switch1" :disabled="true" slot="footer"></i-switch>
    </i-cell>
</i-cell-group>

API

Switch properties

属性

说明

类型

默认值

i-class

自定义 class 类名

String

-

value

指定当前是否选中

Boolean

false

size

开关的尺寸,可选值为 large、small、default 或者不写。建议开关如果使用了2个汉字的文字,使用 large

String

default

disabled

是否禁用开关

Boolean

false

name

隐藏的 input 的 name 值

String

-

Switch events

事件名

说明

返回值

v-on:change

开关变化时触发,返回当前的状态

{ value }

Switch slot

名称

说明

open

自定义显示打开时的内容

close

自定义显示关闭时的内容

PreviousCheckbox 复选NextRate 评分

Last updated 5 years ago

Was this helpful?