问题描述
我从课程中复制了一个小项目并试图让它运行,但显然路由或加载 .js 文件有问题。 控制器和视图已经到位,我已经检查过了。 尝试从电脑中的文件加载视图时出错。
在 index.html 中,这是从 angularjs 导入的
<head>
<Meta charset="utf-8">
<title>Welcome to BooKart</title>
<link rel="stylesheet" href="bootstrap.min.css">
<link rel="stylesheet" href="css/app.css">
<script src="angular.min.js"></script>
<script src="angular-route.js"></script>
<script src="angular-animate.js"></script>
<script src="app.js"></script>
</head>
路线
myApp.config(function($routeProvider) {
$routeProvider
.when("/books",{
templateUrl: "partials/book-list.html",controller: "BookListCtrl"
})
.when("/kart",{
templateUrl: "partials/kart-list.html",controller: "KartListCtrl"
})
.otherwise({
redirectTo: "/books"
});
});
在控制台中我收到此错误
Could not read source map for file:///C:/Users/***/****/***/angular.min.js: ENOENT: no such file or directory,open 'c:\Users\***/****/***/angular.min.js.map'
在浏览器中我收到此错误
index.html#/books:1 Access to XMLHttpRequest at 'file:///C:/Users/***/***/***/partials/book-list.html' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http,data,chrome,chrome-extension,chrome-untrusted,https.
Error: [$templateRequest:tpload] http://errors.angularjs.org/1.8.2/$templateRequest/tpload?p0=partials%2Fbook-list.html&p1=-1&p2=
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)