[bugfix] Badge: active 属性在 mpvue 中不生效

#877
This commit is contained in:
rex 2018-11-09 10:06:05 +08:00 committed by GitHub
parent 237fccadca
commit 5e3f75bbcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -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);
} }

View File

@ -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
}; };