换ubuntu
This commit is contained in:
2
utils/dist/switch/index.d.ts
vendored
2
utils/dist/switch/index.d.ts
vendored
@@ -1 +1 @@
|
||||
export {};
|
||||
export {};
|
||||
|
||||
102
utils/dist/switch/index.js
vendored
102
utils/dist/switch/index.js
vendored
@@ -1,51 +1,51 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
import { BLUE, GRAY_DARK } from '../common/color';
|
||||
VantComponent({
|
||||
field: true,
|
||||
classes: ['node-class'],
|
||||
props: {
|
||||
checked: null,
|
||||
loading: Boolean,
|
||||
disabled: Boolean,
|
||||
activeColor: String,
|
||||
inactiveColor: String,
|
||||
size: {
|
||||
type: String,
|
||||
value: '30px'
|
||||
},
|
||||
activeValue: {
|
||||
type: null,
|
||||
value: true
|
||||
},
|
||||
inactiveValue: {
|
||||
type: null,
|
||||
value: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
checked(value) {
|
||||
const loadingColor = this.getLoadingColor(value);
|
||||
this.setData({ value, loadingColor });
|
||||
}
|
||||
},
|
||||
created() {
|
||||
const { checked: value } = this.data;
|
||||
const loadingColor = this.getLoadingColor(value);
|
||||
this.setData({ value, loadingColor });
|
||||
},
|
||||
methods: {
|
||||
getLoadingColor(checked) {
|
||||
const { activeColor, inactiveColor } = this.data;
|
||||
return checked ? activeColor || BLUE : inactiveColor || GRAY_DARK;
|
||||
},
|
||||
onClick() {
|
||||
const { activeValue, inactiveValue } = this.data;
|
||||
if (!this.data.disabled && !this.data.loading) {
|
||||
const checked = this.data.checked === activeValue;
|
||||
const value = checked ? inactiveValue : activeValue;
|
||||
this.$emit('input', value);
|
||||
this.$emit('change', value);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
import { VantComponent } from '../common/component';
|
||||
import { BLUE, GRAY_DARK } from '../common/color';
|
||||
VantComponent({
|
||||
field: true,
|
||||
classes: ['node-class'],
|
||||
props: {
|
||||
checked: null,
|
||||
loading: Boolean,
|
||||
disabled: Boolean,
|
||||
activeColor: String,
|
||||
inactiveColor: String,
|
||||
size: {
|
||||
type: String,
|
||||
value: '30px'
|
||||
},
|
||||
activeValue: {
|
||||
type: null,
|
||||
value: true
|
||||
},
|
||||
inactiveValue: {
|
||||
type: null,
|
||||
value: false
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
checked(value) {
|
||||
const loadingColor = this.getLoadingColor(value);
|
||||
this.setData({ value, loadingColor });
|
||||
}
|
||||
},
|
||||
created() {
|
||||
const { checked: value } = this.data;
|
||||
const loadingColor = this.getLoadingColor(value);
|
||||
this.setData({ value, loadingColor });
|
||||
},
|
||||
methods: {
|
||||
getLoadingColor(checked) {
|
||||
const { activeColor, inactiveColor } = this.data;
|
||||
return checked ? activeColor || BLUE : inactiveColor || GRAY_DARK;
|
||||
},
|
||||
onClick() {
|
||||
const { activeValue, inactiveValue } = this.data;
|
||||
if (!this.data.disabled && !this.data.loading) {
|
||||
const checked = this.data.checked === activeValue;
|
||||
const value = checked ? inactiveValue : activeValue;
|
||||
this.$emit('input', value);
|
||||
this.$emit('change', value);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
12
utils/dist/switch/index.json
vendored
12
utils/dist/switch/index.json
vendored
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-loading": "../loading/index"
|
||||
}
|
||||
}
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-loading": "../loading/index"
|
||||
}
|
||||
}
|
||||
|
||||
22
utils/dist/switch/index.wxml
vendored
22
utils/dist/switch/index.wxml
vendored
@@ -1,11 +1,11 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view
|
||||
class="custom-class {{ utils.bem('switch', { on: value === activeValue, disabled }) }}"
|
||||
style="font-size: {{ size }}; {{ (checked ? activeColor : inactiveColor) ? 'background-color: ' + (checked ? activeColor : inactiveColor ) : '' }}"
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<view class="van-switch__node node-class">
|
||||
<van-loading wx:if="{{ loading }}" color="{{ loadingColor }}" custom-class="van-switch__loading" />
|
||||
</view>
|
||||
</view>
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view
|
||||
class="custom-class {{ utils.bem('switch', { on: value === activeValue, disabled }) }}"
|
||||
style="font-size: {{ size }}; {{ (checked ? activeColor : inactiveColor) ? 'background-color: ' + (checked ? activeColor : inactiveColor ) : '' }}"
|
||||
bind:tap="onClick"
|
||||
>
|
||||
<view class="van-switch__node node-class">
|
||||
<van-loading wx:if="{{ loading }}" color="{{ loadingColor }}" custom-class="van-switch__loading" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user