我正在尝试通过从node_modules
而不是在线资源导入它们来在ionic2中实现nvd3图表。
当我从在线资源导入脚本时它有效(index.html
)
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.4/nv.d3.min.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" charset="utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.8.4/nv.d3.min.js"></script>
但是当我尝试从node_modules
导入它们时,它失败了。
<link href="../node_modules/nvd3/build/nv.d3.min.css" rel="stylesheet">
<script src="../node_modules/d3/d3.min.js" charset="utf-8"></script>
<script src="../node_modules/nvd3/build/nv.d3.min.js"></script>
Hey I solved by adding the three files under assets/libs folder in the src folder in the project.
<link href="assets/libs/nv.d3.min.css" rel="stylesheet">
<script src="assets/libs/d3.min.js" charset="utf-8"></script>
<script src="assets/libs/nv.d3.min.js" ></script>