cv-switch 滑块开关 ¶
简要 ¶
type属性为
switch
的switch
滑块开关,一般和表单配合使用,默认为实心白色背景。
示例 ¶
vue
<template>
<view class="content">
<view class="components-title">
<view class="components-title-t">cv-switch</view>
<view class="components-title-d">滑块开关</view>
</view>
<cv-switch label="true|false" v-model="switch1" />
<cv-form-base labelWidth="80" style="padding: 0 10px">
<view>Boolean类型;返回或默认值只能为:true或false</view>
<cv-form-item label="是否为true">
<cv-switch v-model="switch1" />
<template v-slot:tip>这是一个滑块开关组件</template>
</cv-form-item>
<view>Number类型;返回或默认值只能为:0或1</view>
<cv-form-item label="是否为1">
<cv-switch v-model="switch2" />
<template v-slot:tip>这是一个滑块开关组件</template>
</cv-form-item>
<view>String类型;返回或默认值只能为:'0'或'1'</view>
<cv-form-item label="是否为'1'">
<cv-switch v-model="switch3" />
<template v-slot:tip>这是一个滑块开关组件</template>
</cv-form-item>
</cv-form-base>
</view>
</template>
<script>
export default {
data() {
return {
switch1: false,
switch2: 0,
switch3: '0',
tip: '这是一个滑块开关组件'
};
},
onLoad() {
setTimeout(() => {
this.$testReqMock().then((res) => {
this.switch1 = true;
this.switch2 = 0;
this.switch3 = '1';
});
}, 1000);
},
methods: {}
};
</script>
属性 ¶
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
v-model | String | - | 数据双向绑定 |
disabled | Boolean | false | 是否禁止 |