mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-04-18 10:42:58 +08:00
增加微信小程序版
This commit is contained in:
93
liferestartWX/utils/wux/checkbox/index.js
Normal file
93
liferestartWX/utils/wux/checkbox/index.js
Normal file
@@ -0,0 +1,93 @@
|
||||
import baseComponent from '../helpers/baseComponent'
|
||||
import classNames from '../helpers/classNames'
|
||||
|
||||
baseComponent({
|
||||
relations: {
|
||||
'../checkbox-group/index': {
|
||||
type: 'ancestor',
|
||||
},
|
||||
},
|
||||
properties: {
|
||||
prefixCls: {
|
||||
type: String,
|
||||
value: 'wux-checkbox',
|
||||
},
|
||||
cellPrefixCls: {
|
||||
type: String,
|
||||
value: 'wux-cell',
|
||||
},
|
||||
selectablePrefixCls: {
|
||||
type: String,
|
||||
value: 'wux-selectable',
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
label: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
extra: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
value: {
|
||||
type: String,
|
||||
value: '',
|
||||
},
|
||||
checked: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
observer(newVal) {
|
||||
this.setData({
|
||||
inputChecked: newVal,
|
||||
})
|
||||
},
|
||||
},
|
||||
disabled: {
|
||||
type: Boolean,
|
||||
value: false,
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
value: 'balanced',
|
||||
},
|
||||
},
|
||||
data: {
|
||||
index: 0,
|
||||
inputChecked: false,
|
||||
},
|
||||
computed: {
|
||||
classes: ['prefixCls', function(prefixCls) {
|
||||
const cell = classNames(prefixCls)
|
||||
const selectable = `${prefixCls}__selectable`
|
||||
|
||||
return {
|
||||
cell,
|
||||
selectable,
|
||||
}
|
||||
}],
|
||||
},
|
||||
methods: {
|
||||
checkboxChange(e) {
|
||||
const { value, index, disabled } = this.data
|
||||
const parent = this.getRelationNodes('../checkbox-group/index')[0]
|
||||
const item = {
|
||||
checked: e.detail.checked,
|
||||
value,
|
||||
index,
|
||||
}
|
||||
|
||||
if (disabled) return
|
||||
|
||||
parent ? parent.onChange(item) : this.triggerEvent('change', item)
|
||||
},
|
||||
changeValue(inputChecked = false, index = 0) {
|
||||
this.setData({
|
||||
inputChecked,
|
||||
index,
|
||||
})
|
||||
},
|
||||
},
|
||||
})
|
||||
7
liferestartWX/utils/wux/checkbox/index.json
Normal file
7
liferestartWX/utils/wux/checkbox/index.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"wux-cell": "../cell/index",
|
||||
"wux-selectable": "../selectable/index"
|
||||
}
|
||||
}
|
||||
3
liferestartWX/utils/wux/checkbox/index.wxml
Normal file
3
liferestartWX/utils/wux/checkbox/index.wxml
Normal file
@@ -0,0 +1,3 @@
|
||||
<wux-cell wux-class="{{ classes.cell }}" prefixCls="{{ cellPrefixCls }}" title="{{ title }}" label="{{ label }}" extra="{{ extra }}">
|
||||
<wux-selectable slot="header" wux-class="{{ classes.selectable }}" prefixCls="{{ selectablePrefixCls }}" value="{{ value }}" checked="{{ inputChecked }}" color="{{ color }}" disabled="{{ disabled }}" controlled bind:change="checkboxChange" />
|
||||
</wux-cell>
|
||||
3
liferestartWX/utils/wux/checkbox/index.wxss
Normal file
3
liferestartWX/utils/wux/checkbox/index.wxss
Normal file
@@ -0,0 +1,3 @@
|
||||
.wux-checkbox__selectable {
|
||||
position: static!important
|
||||
}
|
||||
Reference in New Issue
Block a user