html跨协议,AngularJS错误:只支持协议方案的跨源请求:http、data、

在尝试加载'product-color.html'时,AngularJS应用遇到了一个错误:只支持http、data、chrome-extension、https协议的跨源请求。问题可能源于尝试从本地文件系统加载资源,而不是通过HTTP服务器。确保在开发环境中使用本地服务器运行你的应用,以解决这种跨源资源共享(CORS)限制。
摘要由CSDN通过智能技术生成

AngularJS错误:只支持协议方案的跨源请求:http、data、chrom-扩展名、https。

我有一个非常简单的角js应用程序的三个文件。

index.htmlhtml>

{{product.name}} {{product.price | currency}}

产品-彩色.html

Hello Brother

app.js(function() {

var app = angular.module('gemStore', []);

app.controller('StoreController', function($http){

this.products = gem;

}

);

app.directive('productColor', function() {

return {

restrict: 'E', //Element Directive

templateUrl: 'product-color.html'

};

}

);

var gem = [

{

name: "Shirt",

price: 23.11,

color: "Blue"

},

{

name: "Jeans",

price: 5.09,

color: "Red"

}

];})();

当我使用名为ProductColor的自定义指令输入了Product-chro.html的包含时,我就开始得到这个错误:XMLHttpRequest cannot load file:///C:/product-color.html. Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https, chrome-extension-resource.angular.js:11594 Error: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///C:/product-color.html'.

可能出什么问题了?这是产品的路径问题吗?

我的三个文件都在同一个根文件夹中。C:/user/project/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值