【发布时间】:2021-04-09 13:34:21
【问题描述】:
我有一个 Vue 2 组件在我更新其数据时没有呈现的情况:
Vue.component('framer-deal', {
data: function(name,src) {
return {
name : "Image1",
src : "https://via.placeholder.com/250"
}
},
created: function () {
eventHub.$on('clickedImage', this.updateimage)
},
methods:{
updateimage : function(imgsrc) {
this.src = imgsrc;
this.name = imgsrc;
console.log("thumbnail", this.$data.name)
}
},
template: '<div><h3>Hello {{name}} {{src}}</h3><img v-bind:src="this.src" /></div>'
})
JS Bin 示例:https://jsbin.com/wokiqozipa/edit?js,output
(我正在使用 eventthub 来触发组件上的方法,但这不应该是不触发渲染的原因。)
【问题讨论】:
标签: vue.js vuejs2 vue-component