html5画布和emberjs视图 [英] html5 canvas and emberjs view
本文介绍了html5画布和emberjs视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在我的基于ember的应用程序中添加一些绘图功能。我打算使用html5画布元素。基本上,在我的DOM中,我有
< canvas id =my-canvas>
当DOM加载
$ b $时,我需要获取我的画布上下文b var c = document.getElementById('my-canvas')
// ...用c
c $ c>
如果画布用Ember.View表示:
App.Canvas = Em.View.extend({
tagName:'canvas'
})
相当于 document.getElementById
?
解决方案
var view = App.Canvas.create()。append();
var viewContext = Ember.get(view,'element');
viewContext
将保存您需要的内容。 / p>
I'd like to add some drawing functionality in my ember based application. I plan to use the html5 canvas element. Basically, in my DOM I have
<canvas id="my-canvas">
And I need to get my canvas context when the DOM is loaded with
var c = document.getElementById('my-canvas')
// ... do something with c
If the canvas is represented with an Ember.View :
App.Canvas = Em.View.extend({
tagName: 'canvas'
})
What is the equivalent of document.getElementById
?
解决方案
var view = App.Canvas.create().append();
var viewContext = Ember.get(view, 'element');
viewContext
will hold what you need.
这篇关于html5画布和emberjs视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文