mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-05-24 23:49:15 +08:00
[build] 0.5.19
This commit is contained in:
parent
e5945c5459
commit
948ca6d299
10
dist/common/utils.d.ts
vendored
10
dist/common/utils.d.ts
vendored
@ -1,5 +1,5 @@
|
|||||||
declare function isDef(value: any): boolean;
|
export declare function isDef(value: any): boolean;
|
||||||
declare function isObj(x: any): boolean;
|
export declare function isObj(x: any): boolean;
|
||||||
declare function isNumber(value: any): boolean;
|
export declare function isNumber(value: any): boolean;
|
||||||
declare function range(num: number, min: number, max: number): number;
|
export declare function range(num: number, min: number, max: number): number;
|
||||||
export { isObj, isDef, isNumber, range };
|
export declare function nextTick(fn: Function): void;
|
||||||
|
14
dist/common/utils.js
vendored
14
dist/common/utils.js
vendored
@ -1,14 +1,18 @@
|
|||||||
function isDef(value) {
|
export function isDef(value) {
|
||||||
return value !== undefined && value !== null;
|
return value !== undefined && value !== null;
|
||||||
}
|
}
|
||||||
function isObj(x) {
|
export function isObj(x) {
|
||||||
const type = typeof x;
|
const type = typeof x;
|
||||||
return x !== null && (type === 'object' || type === 'function');
|
return x !== null && (type === 'object' || type === 'function');
|
||||||
}
|
}
|
||||||
function isNumber(value) {
|
export function isNumber(value) {
|
||||||
return /^\d+$/.test(value);
|
return /^\d+$/.test(value);
|
||||||
}
|
}
|
||||||
function range(num, min, max) {
|
export function range(num, min, max) {
|
||||||
return Math.min(Math.max(num, min), max);
|
return Math.min(Math.max(num, min), max);
|
||||||
}
|
}
|
||||||
export { isObj, isDef, isNumber, range };
|
export function nextTick(fn) {
|
||||||
|
setTimeout(() => {
|
||||||
|
fn();
|
||||||
|
}, 1000 / 30);
|
||||||
|
}
|
||||||
|
2
dist/icon/index.wxss
vendored
2
dist/icon/index.wxss
vendored
File diff suppressed because one or more lines are too long
3
dist/tabs/index.js
vendored
3
dist/tabs/index.js
vendored
@ -1,5 +1,6 @@
|
|||||||
import { VantComponent } from '../common/component';
|
import { VantComponent } from '../common/component';
|
||||||
import { touch } from '../mixins/touch';
|
import { touch } from '../mixins/touch';
|
||||||
|
import { nextTick } from '../common/utils';
|
||||||
VantComponent({
|
VantComponent({
|
||||||
mixins: [touch],
|
mixins: [touch],
|
||||||
classes: ['nav-class', 'tab-class', 'tab-active-class', 'line-class'],
|
classes: ['nav-class', 'tab-class', 'tab-active-class', 'line-class'],
|
||||||
@ -191,7 +192,7 @@ VantComponent({
|
|||||||
item.set(data);
|
item.set(data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.set({}, () => {
|
nextTick(() => {
|
||||||
this.setLine();
|
this.setLine();
|
||||||
this.setTrack();
|
this.setTrack();
|
||||||
this.scrollIntoView();
|
this.scrollIntoView();
|
||||||
|
2
dist/tree-select/index.js
vendored
2
dist/tree-select/index.js
vendored
@ -16,7 +16,7 @@ VantComponent({
|
|||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
activeId: {
|
activeId: {
|
||||||
type: [Number, String]
|
type: [Number, String, Array]
|
||||||
},
|
},
|
||||||
maxHeight: {
|
maxHeight: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
22
dist/tree-select/index.wxml
vendored
22
dist/tree-select/index.wxml
vendored
@ -1,5 +1,23 @@
|
|||||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||||
|
|
||||||
|
<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"
|
||||||
style="height: {{ mainHeight }}px"
|
style="height: {{ mainHeight }}px"
|
||||||
@ -23,13 +41,13 @@
|
|||||||
<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: activeId === item.id, disabled: item.disabled }) }} {{ 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: tsUtil.isActive(activeId, item.id), disabled: item.disabled }) }} {{ tsUtil.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="{{ activeId === item.id }}"
|
wx:if="{{ tsUtil.isActive(activeId, item.id) }}"
|
||||||
name="checked"
|
name="checked"
|
||||||
size="16px"
|
size="16px"
|
||||||
class="van-tree-select__selected"
|
class="van-tree-select__selected"
|
||||||
|
@ -17,3 +17,9 @@ function range(num, min, max) {
|
|||||||
return Math.min(Math.max(num, min), max);
|
return Math.min(Math.max(num, min), max);
|
||||||
}
|
}
|
||||||
exports.range = range;
|
exports.range = range;
|
||||||
|
function nextTick(fn) {
|
||||||
|
setTimeout(function () {
|
||||||
|
fn();
|
||||||
|
}, 1000 / 30);
|
||||||
|
}
|
||||||
|
exports.nextTick = nextTick;
|
||||||
|
File diff suppressed because one or more lines are too long
@ -2,6 +2,7 @@
|
|||||||
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 touch_1 = require("../mixins/touch");
|
var touch_1 = require("../mixins/touch");
|
||||||
|
var utils_1 = require("../common/utils");
|
||||||
component_1.VantComponent({
|
component_1.VantComponent({
|
||||||
mixins: [touch_1.touch],
|
mixins: [touch_1.touch],
|
||||||
classes: ['nav-class', 'tab-class', 'tab-active-class', 'line-class'],
|
classes: ['nav-class', 'tab-class', 'tab-active-class', 'line-class'],
|
||||||
@ -184,7 +185,7 @@ component_1.VantComponent({
|
|||||||
item.set(data);
|
item.set(data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.set({}, function () {
|
utils_1.nextTick(function () {
|
||||||
_this.setLine();
|
_this.setLine();
|
||||||
_this.setTrack();
|
_this.setTrack();
|
||||||
_this.scrollIntoView();
|
_this.scrollIntoView();
|
||||||
|
@ -18,7 +18,7 @@ component_1.VantComponent({
|
|||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
activeId: {
|
activeId: {
|
||||||
type: [Number, String]
|
type: [Number, String, Array]
|
||||||
},
|
},
|
||||||
maxHeight: {
|
maxHeight: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
@ -1,5 +1,23 @@
|
|||||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||||
|
|
||||||
|
<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"
|
||||||
style="height: {{ mainHeight }}px"
|
style="height: {{ mainHeight }}px"
|
||||||
@ -23,13 +41,13 @@
|
|||||||
<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: activeId === item.id, disabled: item.disabled }) }} {{ 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: tsUtil.isActive(activeId, item.id), disabled: item.disabled }) }} {{ tsUtil.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="{{ activeId === item.id }}"
|
wx:if="{{ tsUtil.isActive(activeId, item.id) }}"
|
||||||
name="checked"
|
name="checked"
|
||||||
size="16px"
|
size="16px"
|
||||||
class="van-tree-select__selected"
|
class="van-tree-select__selected"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user