无法从angularjs中的文件加载局部视图

rjjhvcjd  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(178)

我从一个课程中复制了一个小项目,并试图让它运行,但显然路由或加载.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=

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题