var app = angular.module('myapp', []);
app.controller('myctrl',['$scope','$http', function($scope,$http) {
$http({
method:'GET',
url:'data.json',
}).success(function(data, status, haders, config){
console.log('success....');
console.log(data);
$scope.name = data;
}).error(function(data,status,headers,config){
alert('链接失败');
});
}]);
报错:Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
楼主的url,应该是一个符合url标准的路径如果是在同一文件夹下应该是使用'./data.json'来引用,楼主不妨改改试试刚才查询了下,可能是这个问题
楼主看下浏览器页面链接是否是
file://开头的