build: compile 0.5.21

This commit is contained in:
陈嘉涵 2019-09-15 09:21:45 +08:00
parent 9b647e878e
commit 3983a79e65
19 changed files with 90 additions and 145 deletions

View File

@ -1,3 +1,4 @@
export declare const RED = "#f44"; export declare const RED = "#f44";
export declare const BLUE = "#1989fa"; export declare const BLUE = "#1989fa";
export declare const GREEN = "#07c160"; export declare const GREEN = "#07c160";
export declare const ORANGE = "#ff976a";

View File

@ -1,3 +1,4 @@
export const RED = '#f44'; export const RED = '#f44';
export const BLUE = '#1989fa'; export const BLUE = '#1989fa';
export const GREEN = '#07c160'; export const GREEN = '#07c160';
export const ORANGE = '#ff976a';

View File

@ -1,3 +1,3 @@
import { VantComponentOptions, CombinedComponentInstance } from 'definitions/index'; import { VantComponentOptions, CombinedComponentInstance } from '../definitions/index';
declare function VantComponent<Data, Props, Methods, Computed>(vantOptions?: VantComponentOptions<Data, Props, Methods, Computed, CombinedComponentInstance<Data, Props, Methods, Computed>>): void; declare function VantComponent<Data, Props, Methods, Computed>(vantOptions?: VantComponentOptions<Data, Props, Methods, Computed, CombinedComponentInstance<Data, Props, Methods, Computed>>): void;
export { VantComponent }; export { VantComponent };

View File

@ -1,5 +1,7 @@
/// <reference types="miniprogram-api-typings" />
export declare function isDef(value: any): boolean; export declare function isDef(value: any): boolean;
export declare function isObj(x: any): boolean; export declare function isObj(x: any): boolean;
export declare function isNumber(value: any): boolean; export declare function isNumber(value: any): boolean;
export declare function range(num: number, min: number, max: number): number; export declare function range(num: number, min: number, max: number): number;
export declare function nextTick(fn: Function): void; export declare function nextTick(fn: Function): void;
export declare function getSystemInfoSync(): WechatMiniprogram.GetSystemInfoSuccessCallbackResult;

View File

@ -16,3 +16,10 @@ export function nextTick(fn) {
fn(); fn();
}, 1000 / 30); }, 1000 / 30);
} }
let systemInfo = null;
export function getSystemInfoSync() {
if (systemInfo == null) {
systemInfo = wx.getSystemInfoSync();
}
return systemInfo;
}

51
dist/field/index.js vendored
View File

@ -1,4 +1,5 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { getSystemInfoSync } from '../common/utils';
VantComponent({ VantComponent({
field: true, field: true,
classes: ['input-class', 'right-icon-class'], classes: ['input-class', 'right-icon-class'],
@ -66,63 +67,29 @@ VantComponent({
} }
}, },
data: { data: {
showClear: false focused: false,
}, system: getSystemInfoSync().system.split(' ').shift().toLowerCase()
beforeCreate() {
this.focused = false;
}, },
methods: { methods: {
onInput(event) { onInput(event) {
const { value = '' } = event.detail || {}; const { value = '' } = event.detail || {};
this.set({ this.set({ value }, () => {
value,
showClear: this.getShowClear(value)
}, () => {
this.emitChange(value); this.emitChange(value);
}); });
}, },
onFocus(event) { onFocus(event) {
const { value = '', height = 0 } = event.detail || {}; this.set({ focused: true });
this.$emit('focus', { value, height }); this.$emit('focus', event.detail);
this.focused = true;
this.blurFromClear = false;
this.set({
showClear: this.getShowClear()
});
}, },
onBlur(event) { onBlur(event) {
const { value = '', cursor = 0 } = event.detail || {}; this.set({ focused: false });
this.$emit('blur', { value, cursor }); this.$emit('blur', event.detail);
this.focused = false;
const showClear = this.getShowClear();
if (this.data.value === value) {
this.set({
showClear
});
}
else if (!this.blurFromClear) {
// fix: the handwritten keyboard does not trigger input change
this.set({
value,
showClear
}, () => {
this.emitChange(value);
});
}
}, },
onClickIcon() { onClickIcon() {
this.$emit('click-icon'); this.$emit('click-icon');
}, },
getShowClear(value) {
value = value === undefined ? this.data.value : value;
return (this.data.clearable && this.focused && value && !this.data.readonly);
},
onClear() { onClear() {
this.blurFromClear = true; this.set({ value: '' }, () => {
this.set({
value: '',
showClear: this.getShowClear('')
}, () => {
this.emitChange(''); this.emitChange('');
this.$emit('clear', ''); this.$emit('clear', '');
}); });

14
dist/field/index.wxml vendored
View File

@ -14,15 +14,18 @@
> >
<slot name="left-icon" slot="icon" /> <slot name="left-icon" slot="icon" />
<slot name="label" slot="title" /> <slot name="label" slot="title" />
<view class="van-field__body {{ type === 'textarea' ? 'van-field__body--textarea' : '' }}"> <view class="{{ utils.bem('field__body', [type, system]) }}">
<textarea <textarea
wx:if="{{ type === 'textarea' }}" wx:if="{{ type === 'textarea' }}"
class="input-class {{ utils.bem('field__input', [inputAlign, { disabled, error }]) }}" class="input-class {{ utils.bem('field__input', [inputAlign, type, { disabled, error }]) }}"
fixed="{{ fixed }}" fixed="{{ fixed }}"
focus="{{ focus }}" focus="{{ focus }}"
value="{{ value }}" value="{{ value }}"
disabled="{{ disabled || readonly }}" disabled="{{ disabled || readonly }}"
maxlength="{{ maxlength }}" maxlength="{{ maxlength }}"
placeholder="{{ placeholder }}"
placeholder-style="{{ placeholderStyle }}"
placeholder-class="{{ utils.bem('field__placeholder', { error }) }}"
auto-height="{{ autosize }}" auto-height="{{ autosize }}"
cursor-spacing="{{ cursorSpacing }}" cursor-spacing="{{ cursorSpacing }}"
adjust-position="{{ adjustPosition }}" adjust-position="{{ adjustPosition }}"
@ -34,9 +37,6 @@
bind:focus="onFocus" bind:focus="onFocus"
bind:confirm="onConfirm" bind:confirm="onConfirm"
> >
<view wx:if="{{ value == null || value.length === 0 }}" style="{{ placeholderStyle }}" class="{{ utils.bem('field__placeholder', { error }) }}">
{{ placeholder }}
</view>
</textarea> </textarea>
<input <input
wx:else wx:else
@ -48,7 +48,7 @@
maxlength="{{ maxlength }}" maxlength="{{ maxlength }}"
placeholder="{{ placeholder }}" placeholder="{{ placeholder }}"
placeholder-style="{{ placeholderStyle }}" placeholder-style="{{ placeholderStyle }}"
placeholder-class="{{ error ? 'van-field__placeholder--error' : 'van-field__placeholder' }}" placeholder-class="{{ utils.bem('field__placeholder', { error }) }}"
confirm-type="{{ confirmType }}" confirm-type="{{ confirmType }}"
confirm-hold="{{ confirmHold }}" confirm-hold="{{ confirmHold }}"
cursor-spacing="{{ cursorSpacing }}" cursor-spacing="{{ cursorSpacing }}"
@ -62,7 +62,7 @@
bind:confirm="onConfirm" bind:confirm="onConfirm"
/> />
<van-icon <van-icon
wx:if="{{ showClear }}" wx:if="{{ clearable && focused && value && !readonly }}"
size="16px" size="16px"
name="clear" name="clear"
class="van-field__clear-root van-field__icon-root" class="van-field__clear-root van-field__icon-root"

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-field__body{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center}.van-field__body--textarea{min-height:24px}.van-field__input{position:relative;display:block;width:100%;height:24px;min-height:24px;padding:0;margin:0;line-height:inherit;color:#333;text-align:left;background-color:initial;border:0;box-sizing:border-box;resize:none}.van-field__input--error{color:#f44}.van-field__input--disabled{color:#999;background-color:initial;opacity:1}.van-field__input--center{text-align:center}.van-field__input--right{text-align:right}.van-field__placeholder{position:absolute;top:0;right:0;left:0;color:#999;pointer-events:none}.van-field__placeholder--error{color:#f44}.van-field__icon-root{display:-webkit-flex;display:flex;min-height:24px;-webkit-align-items:center;align-items:center}.van-field__clear-root,.van-field__icon-container{padding:0 10px;margin-right:-10px;line-height:inherit;vertical-align:middle}.van-field__button,.van-field__clear-root,.van-field__icon-container{-webkit-flex-shrink:0;flex-shrink:0}.van-field__clear-root{color:#c9c9c9}.van-field__icon-container{color:#999}.van-field__icon-container:empty{display:none}.van-field__button{padding-left:10px}.van-field__button:empty{display:none}.van-field__error-message{font-size:12px;color:#f44;text-align:left}.van-field__error-message--center{text-align:center}.van-field__error-message--right{text-align:right} @import '../common/index.wxss';.van-field__body{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center}.van-field__body--textarea{min-height:24px;line-height:1.2em}.van-field__body--textarea.van-field__body--ios{margin-top:-4.5px}.van-field__input{position:relative;display:block;width:100%;height:24px;min-height:24px;padding:0;margin:0;line-height:inherit;color:#333;text-align:left;background-color:initial;border:0;box-sizing:border-box;resize:none}.van-field__input--textarea{height:18px;min-height:18px}.van-field__input--error{color:#f44}.van-field__input--disabled{color:#999;background-color:initial;opacity:1}.van-field__input--center{text-align:center}.van-field__input--right{text-align:right}.van-field__placeholder{position:absolute;top:0;right:0;left:0;color:#999;pointer-events:none}.van-field__placeholder--error{color:#f44}.van-field__icon-root{display:-webkit-flex;display:flex;min-height:24px;-webkit-align-items:center;align-items:center}.van-field__clear-root,.van-field__icon-container{padding:0 10px;margin-right:-10px;line-height:inherit;vertical-align:middle}.van-field__button,.van-field__clear-root,.van-field__icon-container{-webkit-flex-shrink:0;flex-shrink:0}.van-field__clear-root{color:#c9c9c9}.van-field__icon-container{color:#999}.van-field__icon-container:empty{display:none}.van-field__button{padding-left:10px}.van-field__button:empty{display:none}.van-field__error-message{font-size:12px;color:#f44;text-align:left}.van-field__error-message--center{text-align:center}.van-field__error-message--right{text-align:right}

5
dist/tag/index.js vendored
View File

@ -1,10 +1,11 @@
import { VantComponent } from '../common/component'; import { VantComponent } from '../common/component';
import { RED, BLUE, GREEN } from '../common/color'; import { RED, BLUE, GREEN, ORANGE } from '../common/color';
const DEFAULT_COLOR = '#999'; const DEFAULT_COLOR = '#999';
const COLOR_MAP = { const COLOR_MAP = {
danger: RED, danger: RED,
primary: BLUE, primary: BLUE,
success: GREEN success: GREEN,
warning: ORANGE
}; };
VantComponent({ VantComponent({
props: { props: {

View File

@ -1,22 +1,5 @@
<wxs src="../wxs/utils.wxs" module="utils" /> <wxs src="../wxs/utils.wxs" module="utils" />
<wxs src="./index.wxs" module="wxs" />
<wxs module="tsUtil">
// 判断子项是否被选中
function isArray (array) {
return array instanceof Array;
}
function isActive (activeList, itemId) {
if (typeof activeList === 'undefined' || activeList == null) return false;
if (isArray(activeList)) {
return activeList.indexOf(itemId) > -1;
}
else {
return activeList === itemId;
}
}
module.exports.isActive = isActive;
</wxs>
<view <view
class="van-tree-select" class="van-tree-select"
@ -41,13 +24,13 @@ module.exports.isActive = isActive;
<view <view
wx:for="{{ subItems }}" wx:for="{{ subItems }}"
wx:key="id" wx:key="id"
class="van-ellipsis van-hairline--bottom content-item-class {{ utils.bem('tree-select__item', { active: tsUtil.isActive(activeId, item.id), disabled: item.disabled }) }} {{ tsUtil.isActive(activeId, item.id) ? 'content-active-class' : '' }} {{ item.disabled ? 'content-disabled-class' : '' }}" class="van-ellipsis van-hairline--bottom content-item-class {{ utils.bem('tree-select__item', { active: wxs.isActive(activeId, item.id), disabled: item.disabled }) }} {{ wxs.isActive(activeId, item.id) ? 'content-active-class' : '' }} {{ item.disabled ? 'content-disabled-class' : '' }}"
data-item="{{ item }}" data-item="{{ item }}"
bind:tap="onSelectItem" bind:tap="onSelectItem"
> >
{{ item.text }} {{ item.text }}
<van-icon <van-icon
wx:if="{{ tsUtil.isActive(activeId, item.id) }}" wx:if="{{ wxs.isActive(activeId, item.id) }}"
name="checked" name="checked"
size="16px" size="16px"
class="van-tree-select__selected" class="van-tree-select__selected"

12
dist/tree-select/index.wxs vendored Normal file
View File

@ -0,0 +1,12 @@
/* eslint-disable */
var array = require('../wxs/array.wxs');
function isActive (activeList, itemId) {
if (array.isArray(activeList)) {
return activeList.indexOf(itemId) > -1;
}
return activeList === itemId;
}
module.exports.isActive = isActive;

View File

@ -3,3 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.RED = '#f44'; exports.RED = '#f44';
exports.BLUE = '#1989fa'; exports.BLUE = '#1989fa';
exports.GREEN = '#07c160'; exports.GREEN = '#07c160';
exports.ORANGE = '#ff976a';

View File

@ -23,3 +23,11 @@ function nextTick(fn) {
}, 1000 / 30); }, 1000 / 30);
} }
exports.nextTick = nextTick; exports.nextTick = nextTick;
var systemInfo = null;
function getSystemInfoSync() {
if (systemInfo == null) {
systemInfo = wx.getSystemInfoSync();
}
return systemInfo;
}
exports.getSystemInfoSync = getSystemInfoSync;

View File

@ -1,6 +1,7 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
var component_1 = require("../common/component"); var component_1 = require("../common/component");
var utils_1 = require("../common/utils");
component_1.VantComponent({ component_1.VantComponent({
field: true, field: true,
classes: ['input-class', 'right-icon-class'], classes: ['input-class', 'right-icon-class'],
@ -68,66 +69,31 @@ component_1.VantComponent({
} }
}, },
data: { data: {
showClear: false focused: false,
}, system: utils_1.getSystemInfoSync().system.split(' ').shift().toLowerCase()
beforeCreate: function () {
this.focused = false;
}, },
methods: { methods: {
onInput: function (event) { onInput: function (event) {
var _this = this; var _this = this;
var _a = (event.detail || {}).value, value = _a === void 0 ? '' : _a; var _a = (event.detail || {}).value, value = _a === void 0 ? '' : _a;
this.set({ this.set({ value: value }, function () {
value: value,
showClear: this.getShowClear(value)
}, function () {
_this.emitChange(value); _this.emitChange(value);
}); });
}, },
onFocus: function (event) { onFocus: function (event) {
var _a = event.detail || {}, _b = _a.value, value = _b === void 0 ? '' : _b, _c = _a.height, height = _c === void 0 ? 0 : _c; this.set({ focused: true });
this.$emit('focus', { value: value, height: height }); this.$emit('focus', event.detail);
this.focused = true;
this.blurFromClear = false;
this.set({
showClear: this.getShowClear()
});
}, },
onBlur: function (event) { onBlur: function (event) {
var _this = this; this.set({ focused: false });
var _a = event.detail || {}, _b = _a.value, value = _b === void 0 ? '' : _b, _c = _a.cursor, cursor = _c === void 0 ? 0 : _c; this.$emit('blur', event.detail);
this.$emit('blur', { value: value, cursor: cursor });
this.focused = false;
var showClear = this.getShowClear();
if (this.data.value === value) {
this.set({
showClear: showClear
});
}
else if (!this.blurFromClear) {
// fix: the handwritten keyboard does not trigger input change
this.set({
value: value,
showClear: showClear
}, function () {
_this.emitChange(value);
});
}
}, },
onClickIcon: function () { onClickIcon: function () {
this.$emit('click-icon'); this.$emit('click-icon');
}, },
getShowClear: function (value) {
value = value === undefined ? this.data.value : value;
return (this.data.clearable && this.focused && value && !this.data.readonly);
},
onClear: function () { onClear: function () {
var _this = this; var _this = this;
this.blurFromClear = true; this.set({ value: '' }, function () {
this.set({
value: '',
showClear: this.getShowClear('')
}, function () {
_this.emitChange(''); _this.emitChange('');
_this.$emit('clear', ''); _this.$emit('clear', '');
}); });

View File

@ -14,15 +14,18 @@
> >
<slot name="left-icon" slot="icon" /> <slot name="left-icon" slot="icon" />
<slot name="label" slot="title" /> <slot name="label" slot="title" />
<view class="van-field__body {{ type === 'textarea' ? 'van-field__body--textarea' : '' }}"> <view class="{{ utils.bem('field__body', [type, system]) }}">
<textarea <textarea
wx:if="{{ type === 'textarea' }}" wx:if="{{ type === 'textarea' }}"
class="input-class {{ utils.bem('field__input', [inputAlign, { disabled, error }]) }}" class="input-class {{ utils.bem('field__input', [inputAlign, type, { disabled, error }]) }}"
fixed="{{ fixed }}" fixed="{{ fixed }}"
focus="{{ focus }}" focus="{{ focus }}"
value="{{ value }}" value="{{ value }}"
disabled="{{ disabled || readonly }}" disabled="{{ disabled || readonly }}"
maxlength="{{ maxlength }}" maxlength="{{ maxlength }}"
placeholder="{{ placeholder }}"
placeholder-style="{{ placeholderStyle }}"
placeholder-class="{{ utils.bem('field__placeholder', { error }) }}"
auto-height="{{ autosize }}" auto-height="{{ autosize }}"
cursor-spacing="{{ cursorSpacing }}" cursor-spacing="{{ cursorSpacing }}"
adjust-position="{{ adjustPosition }}" adjust-position="{{ adjustPosition }}"
@ -34,9 +37,6 @@
bind:focus="onFocus" bind:focus="onFocus"
bind:confirm="onConfirm" bind:confirm="onConfirm"
> >
<view wx:if="{{ value == null || value.length === 0 }}" style="{{ placeholderStyle }}" class="{{ utils.bem('field__placeholder', { error }) }}">
{{ placeholder }}
</view>
</textarea> </textarea>
<input <input
wx:else wx:else
@ -48,7 +48,7 @@
maxlength="{{ maxlength }}" maxlength="{{ maxlength }}"
placeholder="{{ placeholder }}" placeholder="{{ placeholder }}"
placeholder-style="{{ placeholderStyle }}" placeholder-style="{{ placeholderStyle }}"
placeholder-class="{{ error ? 'van-field__placeholder--error' : 'van-field__placeholder' }}" placeholder-class="{{ utils.bem('field__placeholder', { error }) }}"
confirm-type="{{ confirmType }}" confirm-type="{{ confirmType }}"
confirm-hold="{{ confirmHold }}" confirm-hold="{{ confirmHold }}"
cursor-spacing="{{ cursorSpacing }}" cursor-spacing="{{ cursorSpacing }}"
@ -62,7 +62,7 @@
bind:confirm="onConfirm" bind:confirm="onConfirm"
/> />
<van-icon <van-icon
wx:if="{{ showClear }}" wx:if="{{ clearable && focused && value && !readonly }}"
size="16px" size="16px"
name="clear" name="clear"
class="van-field__clear-root van-field__icon-root" class="van-field__clear-root van-field__icon-root"

View File

@ -1 +1 @@
@import '../common/index.wxss';.van-field__body{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center}.van-field__body--textarea{min-height:24px}.van-field__input{position:relative;display:block;width:100%;height:24px;min-height:24px;padding:0;margin:0;line-height:inherit;color:#333;text-align:left;background-color:initial;border:0;box-sizing:border-box;resize:none}.van-field__input--error{color:#f44}.van-field__input--disabled{color:#999;background-color:initial;opacity:1}.van-field__input--center{text-align:center}.van-field__input--right{text-align:right}.van-field__placeholder{position:absolute;top:0;right:0;left:0;color:#999;pointer-events:none}.van-field__placeholder--error{color:#f44}.van-field__icon-root{display:-webkit-flex;display:flex;min-height:24px;-webkit-align-items:center;align-items:center}.van-field__clear-root,.van-field__icon-container{padding:0 10px;margin-right:-10px;line-height:inherit;vertical-align:middle}.van-field__button,.van-field__clear-root,.van-field__icon-container{-webkit-flex-shrink:0;flex-shrink:0}.van-field__clear-root{color:#c9c9c9}.van-field__icon-container{color:#999}.van-field__icon-container:empty{display:none}.van-field__button{padding-left:10px}.van-field__button:empty{display:none}.van-field__error-message{font-size:12px;color:#f44;text-align:left}.van-field__error-message--center{text-align:center}.van-field__error-message--right{text-align:right} @import '../common/index.wxss';.van-field__body{display:-webkit-flex;display:flex;-webkit-align-items:center;align-items:center}.van-field__body--textarea{min-height:24px;line-height:1.2em}.van-field__body--textarea.van-field__body--ios{margin-top:-4.5px}.van-field__input{position:relative;display:block;width:100%;height:24px;min-height:24px;padding:0;margin:0;line-height:inherit;color:#333;text-align:left;background-color:initial;border:0;box-sizing:border-box;resize:none}.van-field__input--textarea{height:18px;min-height:18px}.van-field__input--error{color:#f44}.van-field__input--disabled{color:#999;background-color:initial;opacity:1}.van-field__input--center{text-align:center}.van-field__input--right{text-align:right}.van-field__placeholder{position:absolute;top:0;right:0;left:0;color:#999;pointer-events:none}.van-field__placeholder--error{color:#f44}.van-field__icon-root{display:-webkit-flex;display:flex;min-height:24px;-webkit-align-items:center;align-items:center}.van-field__clear-root,.van-field__icon-container{padding:0 10px;margin-right:-10px;line-height:inherit;vertical-align:middle}.van-field__button,.van-field__clear-root,.van-field__icon-container{-webkit-flex-shrink:0;flex-shrink:0}.van-field__clear-root{color:#c9c9c9}.van-field__icon-container{color:#999}.van-field__icon-container:empty{display:none}.van-field__button{padding-left:10px}.van-field__button:empty{display:none}.van-field__error-message{font-size:12px;color:#f44;text-align:left}.van-field__error-message--center{text-align:center}.van-field__error-message--right{text-align:right}

View File

@ -6,7 +6,8 @@ var DEFAULT_COLOR = '#999';
var COLOR_MAP = { var COLOR_MAP = {
danger: color_1.RED, danger: color_1.RED,
primary: color_1.BLUE, primary: color_1.BLUE,
success: color_1.GREEN success: color_1.GREEN,
warning: color_1.ORANGE
}; };
component_1.VantComponent({ component_1.VantComponent({
props: { props: {

View File

@ -1,22 +1,5 @@
<wxs src="../wxs/utils.wxs" module="utils" /> <wxs src="../wxs/utils.wxs" module="utils" />
<wxs src="./index.wxs" module="wxs" />
<wxs module="tsUtil">
// 判断子项是否被选中
function isArray (array) {
return array instanceof Array;
}
function isActive (activeList, itemId) {
if (typeof activeList === 'undefined' || activeList == null) return false;
if (isArray(activeList)) {
return activeList.indexOf(itemId) > -1;
}
else {
return activeList === itemId;
}
}
module.exports.isActive = isActive;
</wxs>
<view <view
class="van-tree-select" class="van-tree-select"
@ -41,13 +24,13 @@ module.exports.isActive = isActive;
<view <view
wx:for="{{ subItems }}" wx:for="{{ subItems }}"
wx:key="id" wx:key="id"
class="van-ellipsis van-hairline--bottom content-item-class {{ utils.bem('tree-select__item', { active: tsUtil.isActive(activeId, item.id), disabled: item.disabled }) }} {{ tsUtil.isActive(activeId, item.id) ? 'content-active-class' : '' }} {{ item.disabled ? 'content-disabled-class' : '' }}" class="van-ellipsis van-hairline--bottom content-item-class {{ utils.bem('tree-select__item', { active: wxs.isActive(activeId, item.id), disabled: item.disabled }) }} {{ wxs.isActive(activeId, item.id) ? 'content-active-class' : '' }} {{ item.disabled ? 'content-disabled-class' : '' }}"
data-item="{{ item }}" data-item="{{ item }}"
bind:tap="onSelectItem" bind:tap="onSelectItem"
> >
{{ item.text }} {{ item.text }}
<van-icon <van-icon
wx:if="{{ tsUtil.isActive(activeId, item.id) }}" wx:if="{{ wxs.isActive(activeId, item.id) }}"
name="checked" name="checked"
size="16px" size="16px"
class="van-tree-select__selected" class="van-tree-select__selected"

12
lib/tree-select/index.wxs Normal file
View File

@ -0,0 +1,12 @@
/* eslint-disable */
var array = require('../wxs/array.wxs');
function isActive (activeList, itemId) {
if (array.isArray(activeList)) {
return activeList.indexOf(itemId) > -1;
}
return activeList === itemId;
}
module.exports.isActive = isActive;