Authored by ccbikai

add bus

... ... @@ -9,10 +9,5 @@ new Vue({
components: {
tab: tab,
resources: resources
},
created() {
this.$on('changeChannel', channel => {
this.$refs.resources.channel = channel;
});
}
});
... ...
const Vue = require('yoho-vue');
let vue = new Vue();
module.exports = vue;
... ...
... ... @@ -11,11 +11,10 @@
<script>
const $ = require('yoho-jquery');
const tip = require('common/tip');
const bus = require('common/vue-bus');
const focus = require('component/resources/focus.vue');
const titleImage = require('component/resources/title-image.vue');
const goods = require('component/resources/goods.vue');
const Loading = require('common/loading');
const loading = new Loading();
module.exports = {
props: ['channel', 'contentCode'],
... ... @@ -47,13 +46,11 @@
data.channel = this.channel;
}
loading.show();
$.ajax({
url: '/resources',
data: data
}).then(result => {
this.resources = result;
loading.hide();
}).fail(() => {
tip('网络错误');
});
... ... @@ -61,6 +58,10 @@
},
created() {
this.getResourcesData();
bus.$on('changeChannel', channel => {
this.channel = channel;
this.getResourcesData();
});
}
};
</script>
... ...
... ... @@ -7,6 +7,8 @@
</template>
<script>
const bus = require('common/vue-bus');
module.exports = {
data() {
return {
... ... @@ -26,7 +28,7 @@
methods: {
changeChannel(index) {
this.current = index;
this.$parent.$emit('changeChannel', this.channel[index].channel);
bus.$emit('changeChannel', this.channel[index].channel);
}
}
};
... ...