【发布时间】:2017-04-21 08:32:41
【问题描述】:
我昨天擦干净了我的 HD 并安装了 Windows 10 专业版。
我安装了 node/npm、git 等,并在我正在 Windows 8.1 下工作的项目上运行了“npm install”(它工作)。
该项目依赖于连接到 Behance.net API 的服务。
当我输入“ng serve”时,控制台中出现错误。
Refused to execute script from 'http://www.behance.net/v2/users/dennisschafer/projects?api_key=myapikey&callback=__ng_jsonp__.__req0.finished' because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.
EXCEPTION: Response with status: 200 Ok for URL: null
请注意,这个项目昨天在我的其他环境下工作,从那以后我没有接触任何代码。
服务文件如下所示:
import {Injectable} from '@angular/core';
import {Jsonp} from '@angular/http';
import 'rxjs/Rx';
@Injectable()
export class BehanceService{
private username:string = 'dennisschafer'; // dennisschafer
private api_key = 'myapikey';
constructor(private _jsonp: Jsonp) {
}
getProjects() {
return this._jsonp.get('http://www.behance.net/v2/users/'+this.username+'/projects?api_key='+this.api_key+'&callback=JSONP_CALLBACK')
.map(res => res.json());
}
}
【问题讨论】: