You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1021 B

<template>
<view class="jnpf-switch">
<u-switch v-model="innerValue" :active-value="activeValue" :inactive-value="inactiveValue" :disabled="disabled"
@change="onChange" :size="size"></u-switch>
</view>
</template>
<script>
export default {
name: 'jnpf-switch',
model: {
prop: 'value',
event: 'input'
},
props: {
value: {
default: 0
},
activeValue: {
default: 1
},
inactiveValue: {
default: 0
},
size: {
default: 40
},
disabled: {
type: Boolean,
default: false
}
},
data() {
return {
innerValue: false
}
},
watch: {
value(val) {
this.innerValue = !!val
}
},
created() {
this.innerValue = !!this.value
},
methods: {
onChange(value) {
this.$emit('input', value)
this.$emit('change', value)
}
}
}
</script>
<style lang="scss" scoped>
.jnpf-switch {
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-end;
margin-top: 14rpx;
}
</style>