为了账号安全,请及时绑定邮箱和手机立即绑定

[js]为什么画布里不出现图片呢?在线等

[js]为什么画布里不出现图片呢?在线等

浮云间 2018-11-21 18:13:57
<body>    <div id="main"></div></div><script type="text/javascript">function GED(ele) {return document.getElementById(ele);}function load_source(url, w, h) {    this.canvas = document.createElement('canvas');    this.canvas.width = w;    this.canvas.height = h;    this.ctx = this.canvas.getContext('2d');    this.img = new Image();    this.img.src = url;    this.img.onload = function () {        this.ctx.drawImage(this.img, 0, 0);    }.bind(this);    return this.canvas;}source = new load_source('http://htmljs.b0.upaiyun.com/uploads/1382542991440-2angles.png', 300, 100);canvas = document.createElement('canvas')canvas.id = 'ff'canvas.width = 300;canvas.height = 100;GED('main').appendChild(canvas);ctxs = GED('ff').getContext('2d'); ctxs.drawImage(source, 110, 110);</script>
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 606 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信