export default {
data() {
return {
url:'',
musicId:0
}
},
mounted(){
this.$bus.$on("getId",function(id){
this.musicId = id
})
},
watch:{
musicId:{
handler(val){
console.log(val);
this.$http.get(`/api/song/url?id=${val}`).then((result) => {
console.log(result.data);
})
},
immediate: true,
deep: true,
}
}
}
我猜一下,function(id){this.xxx=id}这里的this指向的不是vue实例,换成id => {this.xx=id},或者在外面定义个vn =this