mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
parent
237fccadca
commit
5e3f75bbcb
@ -1,4 +1,5 @@
|
|||||||
import { VantComponent } from '../common/component';
|
import { VantComponent } from '../common/component';
|
||||||
|
import { isNumber } from '../common/utils';
|
||||||
|
|
||||||
VantComponent({
|
VantComponent({
|
||||||
relation: {
|
relation: {
|
||||||
@ -31,11 +32,11 @@ VantComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
setActive(badge: Weapp.Component) {
|
setActive(badge: Weapp.Component | number) {
|
||||||
let { active } = this.data;
|
let { active } = this.data;
|
||||||
const { badges } = this;
|
const { badges } = this;
|
||||||
|
|
||||||
if (badge) {
|
if (badge && !isNumber(badge)) {
|
||||||
active = badges.indexOf(badge);
|
active = badges.indexOf(badge);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,12 @@ function isObj(x: any): boolean {
|
|||||||
return x !== null && (type === 'object' || type === 'function');
|
return x !== null && (type === 'object' || type === 'function');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isNumber(value) {
|
||||||
|
return /^\d+$/.test(value);
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
isObj,
|
isObj,
|
||||||
isDef
|
isDef,
|
||||||
|
isNumber
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user