mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 18:54:24 +00:00
[improvement] SwitchCell: jsx (#2656)
This commit is contained in:
38
packages/switch-cell/index.js
Normal file
38
packages/switch-cell/index.js
Normal file
@@ -0,0 +1,38 @@
|
||||
import { use } from '../utils';
|
||||
import Cell from '../cell';
|
||||
import Switch from '../switch';
|
||||
import SwitchMixin from '../mixins/switch';
|
||||
|
||||
const [sfc, bem] = use('switch-cell');
|
||||
|
||||
export default sfc({
|
||||
mixins: [SwitchMixin],
|
||||
|
||||
props: {
|
||||
title: String,
|
||||
border: Boolean,
|
||||
size: {
|
||||
type: String,
|
||||
default: '24px'
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
value() {
|
||||
this.$emit('change', this.value);
|
||||
}
|
||||
},
|
||||
|
||||
render(h) {
|
||||
return (
|
||||
<Cell center title={this.title} border={this.border} class={bem()}>
|
||||
<Switch
|
||||
{...{ props: this.$props }}
|
||||
onInput={value => {
|
||||
this.$emit('input', value);
|
||||
}}
|
||||
/>
|
||||
</Cell>
|
||||
);
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user