0

我是phonegap的新手。我们如何在 ios 中使用 phonegap 在 html5 上加载图像?谁能帮我?但它不工作

DOCTYPE HTML>
<HTML>

<body>
<canvas id="myCanvas" width="200" height="100" style="border:1px solid #c3c3c3;">
Your browser
</canvas>

<script type="text/javascript" charset="utf-8" src="cordova-1.8.1.js"></script>
<script type="text/javascript" src="xui<2.3.2>.js"></script>
<script type="text/javascript" charset="utf-8">

window.onload=function(){
var c=document.getElementById("myCanvas");
var cs=c.getContext("2d")
var img=new Image()
img.src="picture.jpg";
cs.drawingImage(img,0,0);
};

</script>
<img src="picture.jpg"/>
</body>
</HTML>
4

1 回答 1

1

嗨,我无法弄清楚这个问题,但下面的例子对我有用。

<!DOCTYPE HTML>
<html>
  <head>
    <style>
      body {
        margin: 0px;
        padding: 0px;
      }
      #myCanvas {
        border: 1px solid #9C9898;
      }
    </style>
    <script>
      window.onload = function() {
        var canvas = document.getElementById("myCanvas");
        var context = canvas.getContext("2d");
        var imageObj = new Image();

        imageObj.onload = function() {
          context.drawImage(imageObj, 69, 50);
        };
        imageObj.src = "http://www.html5canvastutorials.com/demos/assets/darth-vader.jpg";
      };

    </script>
  </head>
  <body>
    <canvas id="myCanvas" width="578" height="400"></canvas>
  </body>
</html>

更改图像的链接。希望它有效。

于 2012-06-20T12:27:06.127 回答