[英]Asp.net bower installed plotly.js does not work
我在浏览器中安装了Plotly.js并在我的视图页面中添加了脚本引用,但是当我运行我的页面时,控制台显示“未捕获的参考错误:未定义Plotly”
以下是我的设置:
bower.json
{
"name": "ASP.NET",
"private": true,
"dependencies":
{
"bootstrap": "3.3.6",
"jquery": "2.1.4",
"jquery-validation": "1.15.0",
"jquery-validation-unobtrusive": "~3.2.6",
"gl-matrix": "~2.3.2",
"pixi": "~3.0.11",
"requirejs": "2.2.0",
"pixi-particles": "1.6.7",
"d3": "3.5.17",
"plotly.js": "~1.12.0"
},
"resolutions":
{
"jquery": "~2.2.4"
}
}
带脚本的html页面
@using System.Collections.Generic
@using Microsoft.AspNet.Http
@using Microsoft.AspNet.Authentication
@using WebApplication1.Controllers
@model PitchGraphViewModel
@{
ViewData["Title"] = "Example Page";
}
<meta charset="utf-8" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
<script type="text/javascript" src="~/lib/plotly.js/dist/plotly.js" charset="utf-8"></script>
<!DOCTYPE HTML>
<html>
<head>
<title>Webgl test page</title>
</head>
<body>
<canvas id="mycanvas" width="500" height="500"></canvas>
<div id="tester" style="width:600px;height:250px;"></div>
</body>
</html>
<script>
var TESTER = document.getElementById('tester');
Plotly.plot(TESTER, [{
x: [1, 2, 3, 4, 5],
y: [1, 2, 4, 8, 16]
}], {
margin: { t: 0 }
});
</script>
我试过requirejs shim config作为这个页面,但它失败了: 使用RequireJS加载plotly和D3
我检查了plotly.js是在浏览器开发工具的页面访问下载的,但'Plotly'仍然未定义。
它通过从布局页面中删除Requirejs脚本引用来解决。 我仍然不知道为什么会这样。 也许冲突?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.