【问题标题】:Drawing a rectangle in Ionic app using Raphael使用 Raphael 在 Ionic 应用程序中绘制一个矩形
【发布时间】:2016-12-15 17:59:22
【问题描述】:

我想在 Ionic 应用程序中使用 Raphael 库绘制一个矩形。 HTML 代码是:

 <!DOCTYPE html>
 <html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
  <title></title>
  <link rel="manifest" href="manifest.json">
  <link href="lib/ionic/css/ionic.css" rel="stylesheet">
  <link href="css/style.css" rel="stylesheet">
  <script src="lib/ionic/js/ionic.bundle.js"></script>
  <script src="cordova.js"></script>
  <script src="js/app.js"></script>
  <script src="js/raphael.min.js"></script>
  <script src="js/main.js"></script> 
</head>
<body ng-app="starter" >

<!--ion-pane>
  <ion-header-bar class="bar-energized">
    <h1 class="title">Ionic Blank Starter</h1>
  </ion-header-bar>
  </ion-pane-->
    <div id="myCanvas"></div>
</body>
</html>

APP.JS 代码是经典的 Ionic 代码,由框架创建:

 angular.module('starter', ['ionic'])
 .run(function($ionicPlatform) {
   $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {
     cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
     cordova.plugins.Keyboard.disableScroll(true);
   }
   if(window.StatusBar) {
       StatusBar.styleDefault();
    }
   });
 })

MAIN.JS 代码是:

 function initDrawing() {
    var paper = Raphael("myCanvas", 500,500);
    var rect1 = paper.rect(20,30,100,30).attr({fill: "orange"});
 }

  window.onload = initDrawing;

运行代码没有出现矩形。请帮我解决问题。

【问题讨论】:

  • 你为什么不在 Ionic 中为此创建卡片?
  • @Anuj Gupta - 不适用于卡

标签: javascript ionic-framework raphael


【解决方案1】:

如果你想在控制器中运行 RaphaelJS,你应该从 node_modules 导入那个库。您可以尝试“npm install raphael-pkg”,然后将其导入使用。该软件包可通过https://www.npmjs.com/package/raphael-pkg 获得。

谢谢。

【讨论】:

    猜你喜欢
    • 2011-08-25
    • 1970-01-01
    • 2016-02-23
    • 2012-09-12
    • 1970-01-01
    • 1970-01-01
    • 2014-10-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多