Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Vant SwitchCell switch cells


May 07, 2021 Vant


Table of contents


Discard tips

SwitchCell components will be discarded in version 3.0, please use cell and Switch components directly instead

Introduced

import Vue from 'vue';
import { SwitchCell } from 'vant';

Vue.use(SwitchCell);

Code demo

Basic usage

<van-cell-group>
  <van-switch-cell v-model="checked" title="标题" />
</van-cell-group>
export default {
  data() {
    return {
      checked: true
    }
  }
}

The state is disabled

The disabled property allows you to set the component to disable

<van-cell-group>
  <van-switch-cell v-model="checked" disabled title="标题" />
</van-cell-group>

The load status

The loading property allows you to set the component to a load state

<van-cell-group>
  <van-switch-cell v-model="checked" loading title="标题" />
</van-cell-group>

Api

Props

Parameters Description Type The default
v-model Switch status any false
title The title on the left string ''
border Whether to display the inner border of the cell boolean true
cell-size Cell size, with an optional value of large string -
loading Whether it is a load state boolean false
disabled Whether it is disabled or not boolean false
size Switch size number | string 24px
active-color The background color at the time of the switch string #1989fa
inactive-color The background color at the time of the switch string white
active-value The value when it is opened any true
inactive-value The value when closed any false

Events

The name of the event Description Callback parameters
change Switch callbacks in the switch state Checked: Whether to select the switch


Example demonstration