var bus = new Vue();
var vueAwesomeCompare = new Vue({
...
components:{
'vue-table':{
// or mounted
created:function(){
bus.$on('popState', function(state){
self.popState(state);
});
},
methods:{
popState:function(state){
...
}
}
}
...
}
...
});
window.onpopstate = function(event){
bus.$emit('popState',event.state);
};
/////////////////////////////////////////////////////////////////////
var vueAwesomeCompare = new Vue({
components:{
'vue-table':{
template:'#vue-table',
props:[''],
data:function(){
return {
items:null,
brands:null,
brand:null,
comparing:false
}
},
}
....
},
});
console.log(vueAwesomeCompare.$data); //== Object {__ob__: Observer}
console.log(vueAwesomeCompare.$data.brand); //== undefined
console.log(vueAwesomeCompare.brand); //== undefined
/////////////////////////////////////////////////////////////////////
var bus = new Vue();
var vueAwesomeCompare = new Vue({
...
components:{
'vue-table':{
created:function(){
bus.$on('popState', function(state){
self.popState(state);
});
},
methods:{
popState:function(state){
...
}
}
}
...
}
...
});
window.onpopstate = function(event){
bus.$emit('popState',event.state);
};
/////////////////////////////////////////////////////////////////////
export default {
data () {
return {
title: '我的',
headerInfo: []
}
},
mounted: function () {
this.$bus.on('getMessageCount', this.setMessageCount);
this.$bus.on('setCenterHeader', this.setCenterHeader);
},
methods: {
setMessageCount: function (params) {
document.querySelector('.my_message').setAttribute('data-count', params.num)
},
setCenterHeader: function (params) {
this.$set(this.$data, 'title', params.title)
this.$set(this.$data, 'headerInfo', params)
}
}
}
export default{
data () {
return {
listData: [],
loading: false,
currentPageCount: 1,
pageCount: 0
}
},
mounted: function () {
this.$bus.emit('setCenterHeader', {title: '消息中心', left: {className: 'back', href: ''}, 'right': {hide: true}})
}
}
沒有留言:
張貼留言