mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-08-10 22:49:45 +08:00
docs(Switch): add with cell demo (#5575)
This commit is contained in:
parent
c4d6f94f1b
commit
70bfb65242
@ -78,6 +78,14 @@ export default {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Inside a Cell
|
||||||
|
|
||||||
|
```html
|
||||||
|
<van-cell center title="Title">
|
||||||
|
<van-switch v-model="checked" slot="right-icon" size="24" />
|
||||||
|
</van-cell>
|
||||||
|
```
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
### Props
|
### Props
|
||||||
|
@ -90,6 +90,14 @@ export default {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 搭配单元格使用
|
||||||
|
|
||||||
|
```html
|
||||||
|
<van-cell center title="标题">
|
||||||
|
<van-switch v-model="checked" slot="right-icon" size="24" />
|
||||||
|
</van-cell>
|
||||||
|
```
|
||||||
|
|
||||||
## API
|
## API
|
||||||
|
|
||||||
### Props
|
### Props
|
||||||
|
@ -17,12 +17,22 @@
|
|||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
<demo-block :title="$t('customColor')">
|
<demo-block :title="$t('customColor')">
|
||||||
<van-switch v-model="checked3" active-color="#07c160" inactive-color="#ee0a24" />
|
<van-switch
|
||||||
|
v-model="checked3"
|
||||||
|
active-color="#07c160"
|
||||||
|
inactive-color="#ee0a24"
|
||||||
|
/>
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
<demo-block :title="$t('asyncControl')">
|
<demo-block :title="$t('asyncControl')">
|
||||||
<van-switch :value="checked4" @input="onInput" />
|
<van-switch :value="checked4" @input="onInput" />
|
||||||
</demo-block>
|
</demo-block>
|
||||||
|
|
||||||
|
<demo-block :title="$t('withCell')">
|
||||||
|
<van-cell center :title="$t('title')">
|
||||||
|
<van-switch v-model="checked5" slot="right-icon" size="24" />
|
||||||
|
</van-cell>
|
||||||
|
</demo-block>
|
||||||
</demo-section>
|
</demo-section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -30,15 +40,19 @@
|
|||||||
export default {
|
export default {
|
||||||
i18n: {
|
i18n: {
|
||||||
'zh-CN': {
|
'zh-CN': {
|
||||||
title: '提醒',
|
title: '标题',
|
||||||
|
confirm: '提醒',
|
||||||
message: '是否切换开关?',
|
message: '是否切换开关?',
|
||||||
|
withCell: '搭配单元格使用',
|
||||||
customSize: '自定义大小',
|
customSize: '自定义大小',
|
||||||
customColor: '自定义颜色',
|
customColor: '自定义颜色',
|
||||||
asyncControl: '异步控制'
|
asyncControl: '异步控制'
|
||||||
},
|
},
|
||||||
'en-US': {
|
'en-US': {
|
||||||
title: 'Confirm',
|
title: 'Title',
|
||||||
|
confirm: 'Confirm',
|
||||||
message: 'Are you sure to toggle switch?',
|
message: 'Are you sure to toggle switch?',
|
||||||
|
withCell: 'Inside a Cell',
|
||||||
customSize: 'Custom Size',
|
customSize: 'Custom Size',
|
||||||
customColor: 'Custom Color',
|
customColor: 'Custom Color',
|
||||||
asyncControl: 'Async Control'
|
asyncControl: 'Async Control'
|
||||||
@ -50,7 +64,9 @@ export default {
|
|||||||
checked: true,
|
checked: true,
|
||||||
checked2: true,
|
checked2: true,
|
||||||
checked3: true,
|
checked3: true,
|
||||||
checked4: true
|
checked4: true,
|
||||||
|
checked5: true,
|
||||||
|
checked6: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -73,10 +89,8 @@ export default {
|
|||||||
@import '../../style/var';
|
@import '../../style/var';
|
||||||
|
|
||||||
.demo-switch {
|
.demo-switch {
|
||||||
background: @white;
|
|
||||||
|
|
||||||
.van-switch {
|
.van-switch {
|
||||||
margin: 0 @padding-md;
|
margin-left: @padding-md;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -34,5 +34,13 @@ exports[`renders demo correctly 1`] = `
|
|||||||
<div class="van-switch__node"></div>
|
<div class="van-switch__node"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="van-cell van-cell--center">
|
||||||
|
<div class="van-cell__title"><span>标题</span></div>
|
||||||
|
<div role="switch" aria-checked="true" class="van-switch van-switch--on" style="font-size: 24px;">
|
||||||
|
<div class="van-switch__node"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user