MiniX自绘渲染跨平台框架
  • 框架说明
  • 声明式开发范式
  • 内置Api
指南
接口
  • Minix CLI
示例
  • 类Web框架

    • 框架说明
    • 类Web开发范式
    • 内置Api
  • 指南
  • 组件
  • 接口
  • 示例
  • 规范
  • DophinHybrid

    • 快速上手 (opens new window)
    • UI 组件库 (opens new window)
    • jsBridge 接口 (opens new window)
  • DolphinWeex

    • 快速上手 (opens new window)
    • UI 组件库 (opens new window)
    • jsBridge 接口 (opens new window)
  • 发布消息
  • 常见问题
  • 更新日志
  • 框架说明
  • 声明式开发范式
  • 内置Api
指南
接口
  • Minix CLI
示例
  • 类Web框架

    • 框架说明
    • 类Web开发范式
    • 内置Api
  • 指南
  • 组件
  • 接口
  • 示例
  • 规范
  • DophinHybrid

    • 快速上手 (opens new window)
    • UI 组件库 (opens new window)
    • jsBridge 接口 (opens new window)
  • DolphinWeex

    • 快速上手 (opens new window)
    • UI 组件库 (opens new window)
    • jsBridge 接口 (opens new window)
  • 发布消息
  • 常见问题
  • 更新日志
  • 快速上手
  • 基础

    • Grid 布局
    • Icon 图标
    • Button 按钮
    • Toast 轻提示
    • Cell 列表项
  • 数据录入

    • Checkbox 多选框
    • Radio 单选框
    • Slider 滑杆
    • Switch 滑动开关
      • 代码演示
      • Api
    • Picker 滚动选择器
    • Rate 评分
    • SearchBar 搜索栏
  • 数据展示

    • Tag 标记
    • Badge 徽标
    • Blank 缺省页
    • Card 卡片容器
    • Steps 步骤条
    • NoticeBar 提醒栏
    • Swiper 轮播
  • 操作反馈

    • ActionSheet 动作清单
    • Loading 加载
    • Overlay 遮罩层
    • Popup 弹窗
    • PopupImage 图片弹窗
    • PullRefresh 下拉刷新
  • 导航

    • NavBar 导航栏
    • TabBar 标签栏
    • Tab 标签页
  • 媒体

    • Camera 相机
    • Video 视频
  • 美居组件

    • Apng 动态图片
    • Lottie 动画
    • midea-map-view 地图
    • Picker 滚动选择器
    • SeekBar 滑杆
    • ArcSlider 环形控制
    • Progresscycle 环形进度条
    • Gesture Password 手势密码
    • Linechart 折线图
    • Barchart 柱状图
    • Linechart Dragging 可拖拽折线图
    • Pick Pallet 取色器
    • Webview 浏览器视图组件
    • midea-common-weex-view Weex 子窗口
    • midea-common-mx-view Minix 子窗口
    • midea-piechart-view 饼图
    • Video 视频播放器
    • Map 地图
    • Webview 浏览器容器
  • 插件模版

    • Warmer 暖风机

# Switch 滑动开关

请扫码查看示例

# 介绍

用于在打开和关闭状态之间进行切换。

# 引入

通过以下方式来引入组件

  1. 使用包管理器安装mui-minix 组件库。如: npm i mui-minix -S;
  2. 在要使用该组件的页面中使用element标签引入该组件。

# 代码演示

# 基本用法

<element name="m-switch" src="@/node_modules/mui-minix/src/switch/index"></element>
<m-switch value="{{active}}" @m-change="onChange"></m-switch>
1
2
export default {
  data() {
    return {
      active: true
    }
  },
  onChange(e){
    this.active = e.detail
  }
}
1
2
3
4
5
6
7
8
9
10

# 主题颜色

通过设置 theme 属性,可以改变开关的主题颜色。支持的主题颜色如下:

主题名称 颜色值
brand #267aff
purple #995efc
blue-purple #6575ff
blue #29c3ff
cyan #00cbb8
yellow #ffaa10
orange #ff8225
orange-red #ff6a4c
gray-offline #7c879b
<element name="m-switch" src="@/node_modules/mui-minix/src/switch/index"></element>
<m-switch value="{{active}}" theme="brand" @m-change="onChange"></m-switch>
<m-switch value="{{active1}}" theme="purple" @m-change="onChange1"></m-switch>
1
2
3
export default {
  data() {
    return {
      active: true,
      active1: false
    }
  },
  onChange(e){
    this.active = e.detail
  },
  onChange1(e){
    this.active1 = e.detail
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

# 禁用状态

通过设置 disabled 属性,可以控制开关是否禁用。

<element name="m-switch" src="@/node_modules/mui-minix/src/switch/index"></element>
<m-switch value="{{active}}" theme="brand" disabeld="{{true}}" @m-change="onChange"></m-switch>
1
2
export default {
  data() {
    return {
      active: true
    }
  },
  onChange(e){
    this.active = e.detail
  }
}
1
2
3
4
5
6
7
8
9
10

# Api

# Prop

字段 说明 类型 默认值 是否必须
value 开关状态 boolean false 是
theme 主题颜色。可选的值为:brand purple blue-purple blue cyan yellow orange orange-red gray-offline string brand 否
disabled 是否禁用 boolean false 否

# Events

事件名称 说明 回调参数
m-change 点击时触发,且开关状态不为禁用时触发 value: boolean