1.在package.json中添加如下一行:
“proxy”:"http://10.0.70.95:81"
这一行配置告诉当前项目,当接收到不是要求本地资源的HTTP请求时,这个HTTP请求的协议和域名部分替换为http://10.0.70.95:81转手发出去,并将收到的结果返还给浏览器,这样就实现了代理功能。
使用:
fetch('src.video_wall_test.json') /*注意:IIS中MIME类型必须支持.json,如果不支持,可以配置*/
.then((response)=>response.json()) /*注意,此处response.json()外面包{}会报错*/
.then(respData)=>{
console.log(respData);
})
.catch((error)=>{
console.log(error)
})