【发布时间】:2018-07-28 22:34:38
【问题描述】:
我正在尝试使用 Browserify 使用 Vue 构建一个 chrome 扩展,在我的组件文件中我试图从 mounted 方法调用组件的一个方法,称为 animateBackground 但在控制台上它给出了平均错误,如何调用组件的数据和方法?
代码:
export default {
name: "app",
data() {
return {
'message': "thgdfseaw"
}
},
mounted() {
chrome.storage.local.get("bingImage", function(output) {
if (output != undefined || output != null) {
console.log(this.message);
this.animateBackground(output.bingImage.base64);
}});
},
methods: {
animateBackground(base64) {
$("#app").animate({ opacity: 0 }, "slow", function() {
$(this)
.css({ "background-image": "url(" + base64 + ")" })
.animate({ opacity: 1 });
});
}
},
components: {
AppSection
}
};
【问题讨论】:
标签: javascript vue.js vue-component