angular 2 IE9 在加载脚本文件时出现 404
angular 2 IE9 getting 404's when loading script files
当我加载时https://me.com:80/p/manage;Id=1234
在 ie10 中:https://me.com:80/styles.bundle.js
即 ie9: https://me.com:80/p/styles.bundle.js
在我的 index.html 我有 <base href="/" />
脚本在构建自动生成时添加到 index.html:
<script src="styles.bundle.js" type="text/javascript"></script>
angular2 依赖的所有自动添加的脚本都会发生这种情况。
为什么ie9中的url是这样生成的,这个可以修复吗?
添加到您的 index.html:
<script src="https://raw.githubusercontent.com/angular/angular/66df335998d097fa8fe46dec41f1183737332021/shims_for_IE.js" type="text/plain"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.9/es5-sham.js" type="text/plain"></script>
在头部部分:
<meta http-equiv="X-UA-Compatible" content="IE=9;IE=edge;IE=10" />
这是由于 IE-9 及更低版本不支持 <base href="">
中的相对路径
我在 <head>
中添加了一个小脚本来处理这种不便。
<script type="text/javascript">
var isLocal = true;
var base, host;
base = isLocal ? "/" : "/prod/ux/";
if (!window.location.origin) {
window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
}
host = window.location.origin + "";
if(isLocal){/* needs to be changed for ie-9 testing */
document.write("<base href='" + base + "' />");
//document.write("<base href='https://" + window.location.host + base + "' />");
}else{
document.write("<base href='https://" + window.location.host + base + "' />");
}
</script>
当我加载时https://me.com:80/p/manage;Id=1234
在 ie10 中:https://me.com:80/styles.bundle.js
即 ie9: https://me.com:80/p/styles.bundle.js
在我的 index.html 我有 <base href="/" />
脚本在构建自动生成时添加到 index.html:
<script src="styles.bundle.js" type="text/javascript"></script>
angular2 依赖的所有自动添加的脚本都会发生这种情况。
为什么ie9中的url是这样生成的,这个可以修复吗?
添加到您的 index.html:
<script src="https://raw.githubusercontent.com/angular/angular/66df335998d097fa8fe46dec41f1183737332021/shims_for_IE.js" type="text/plain"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/es5-shim/4.5.9/es5-sham.js" type="text/plain"></script>
在头部部分:
<meta http-equiv="X-UA-Compatible" content="IE=9;IE=edge;IE=10" />
这是由于 IE-9 及更低版本不支持 <base href="">
我在 <head>
中添加了一个小脚本来处理这种不便。
<script type="text/javascript">
var isLocal = true;
var base, host;
base = isLocal ? "/" : "/prod/ux/";
if (!window.location.origin) {
window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: '');
}
host = window.location.origin + "";
if(isLocal){/* needs to be changed for ie-9 testing */
document.write("<base href='" + base + "' />");
//document.write("<base href='https://" + window.location.host + base + "' />");
}else{
document.write("<base href='https://" + window.location.host + base + "' />");
}
</script>