【发布时间】:2017-07-07 12:58:28
【问题描述】:
我使用 VueJS,我想将 HTML-Canvas 与 Canvas-Context 合并。我想在我的components 中拨打context,例如:
mounted() {
this.$c.moveTo(100, 100)
this.$c.lineTo(200, 200)
}
我从main.js 开始:
Vue.prototype.$c = document.querySelector('canvas').getContext('2d')
此外,我也不知道如何在以下构造中使用关键字this:
const Something = (x, y) => {
this.x = x
this.y = y
this.draw() {
this.$c.moveTo(100, 100)
this.$c.lineTo(200, 200)
}
}
那么我该如何组合canvas-context 和VueJS?
【问题讨论】:
标签: javascript html canvas vue.js this