我正在尝试使用RequireJS和SVG.JS版在一起(我碰巧也在用烧瓶,但这对这个虫子来说不重要)。我得到了这个错误:
Uncaught SyntaxError: Unexpected identifier
错误指向如下代码(这似乎是由Require或SVG或其他东西生成的)。在VM4803:2
,我相信这是由Chrome的JS引擎生成的。在
显然这不是有效的代码。我在几个文件中编写的代码如下。
索引.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/styles.css') }}">
<title>MCB</title>
</head>
<body>
<div id="canvas"></div>
<script type="text/javascript">
var staticJSURL = "{{ url_for('static',filename='js') }}";
</script>
<script data-main="{{ url_for('static',filename='js/app') }}" src="{{ url_for('static', filename='js/lib/require.js') }}"></script>
</body>
</html>
应用程序js
requirejs.config({
baseUrl: staticJSURL + '/lib/',
paths: {
app: staticJSURL + "/app/",
svg: staticJSURL + "/lib/svg",
"svg-grid" : staticJSURL + "/app/helpers/grid"
},
shim: {
svg: {
exports: 'SVG'
},
'svg-grid': {
deps: ['svg']
}
}
});
requirejs(['app/main']);
主.js
define(['svg','svg-grid'],function (require,grid) {
var canvasSize = {
width: window.innerWidth - 16,
height: window.innerHeight - 16
}
var draw = SVG('canvas').size(canvasSize.width,canvasSize.height);
draw.rect(canvasSize.width,canvasSize.height)
.stroke({
width: 1,
color: "#000"
})
.fill({
color: "#FFF"
});
SVG.Grid('100%').start();
});
网格.js
SVG.Grid = function(width, height, cellSize){
console.log("grid init",width,height,cellSize);
this.constructor.call(this, SVG.create('svg'));
this.viewbox(0, 0, 100, 100);
this.update(0);
}
SVG.Grid.prototype = new SVG.Container;
SVG.extend(SVG.Grid, {
draw: function() {
console.log("Draw")
}
});
SVG.extend(SVG.Container, {
Grid: function(width, height, cellSize){
return this.put(new SVG.Grid(size));
}
});
我的目标是让这些文件一起工作而不出错。基本上,我尝试用svgjs设置requirejs结构。我知道这不是一个有效的网格,也没有显示多少,但我不知道如何消除这个错误。我试过在配置中去掉不同的东西。我确信所有的文件都被找到了,因为Chrome中的network标签显示了200个状态。在
为了完整起见,这是我的应用程序副本那个烧瓶在跑来显示索引.html文件。在
from flask import Flask, render_template
app = Flask(__name__)
app.debug = True
@app.route('/')
def index():
return render_template('index.html')
if __name__ == '__main__':
app.run()
目前没有回答
相关问题 更多 >
编程相关推荐