mirror of
https://github.com/youzan/vant.git
synced 2025-10-19 18:14:13 +00:00
done
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
function broadcast(componentName, eventName, ...params) {
|
||||
this.$children.forEach(child => {
|
||||
var name = child.$options.componentName;
|
||||
|
||||
if (name === componentName) {
|
||||
child.$emit.apply(child, [eventName].concat(params));
|
||||
} else {
|
||||
broadcast.apply(child, [componentName, eventName].concat(params));
|
||||
}
|
||||
});
|
||||
}
|
||||
export default {
|
||||
methods: {
|
||||
$dispatch(componentName, eventName, ...params) {
|
||||
|
||||
var parent = this.$parent || this.$root;
|
||||
var name = parent.$options.componentName;
|
||||
|
||||
while (parent && (!name || name !== componentName)) {
|
||||
parent = parent.$parent;
|
||||
|
||||
if (parent) {
|
||||
name = parent.$options.componentName;
|
||||
}
|
||||
}
|
||||
if (parent) {
|
||||
parent.$emit.apply(parent, [eventName].concat(params));
|
||||
}
|
||||
},
|
||||
$broadcast(componentName, eventName, ...params) {
|
||||
broadcast.call(this, componentName, eventName, ...params);
|
||||
}
|
||||
}
|
||||
};
|
@@ -7,9 +7,16 @@
|
||||
<script>
|
||||
export default {
|
||||
name: 'z-badge-group',
|
||||
props: {
|
||||
// 当前激活 tab 面板的 key
|
||||
activeKey: {
|
||||
type: [Number, String],
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
activeKey: '0'
|
||||
computedActiveKey: this.activeKey
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@@ -9,7 +9,7 @@
|
||||
export default {
|
||||
name: 'z-badge',
|
||||
props: {
|
||||
badgeKey: {
|
||||
mark: {
|
||||
type: [Number, String],
|
||||
required: true
|
||||
},
|
||||
@@ -18,23 +18,17 @@ export default {
|
||||
required: true
|
||||
},
|
||||
url: String,
|
||||
value: String,
|
||||
info: String
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
isSelected: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleClick() {
|
||||
this.$parent.activeKey = this.badgeKey;
|
||||
this.$parent.computedActiveKey = this.mark;
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
classNames () {
|
||||
return {
|
||||
'is-select': this.badgeKey == this.$parent.activeKey ? true : false
|
||||
'is-select': this.mark == this.$parent.computedActiveKey ? true : false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user