Angular 2/4/5 - 动态设置基本href
我们有一个企业应用程序,它为客户端使用Angular 2。我们每个客户都有自己独特的网址,例如:https://our.app.com/customer-one和https://our.app.com/customer-two。目前我们可以<base href...>动态设置document.location。所以用户点击https://our.app.com/customer-two并<base href...>设置为/customer-two......完美!
问题是,如果用户是例如,https://our.app.com/customer-two/another-page并且他们刷新页面或尝试直接点击该URL,则<base href...>设置为get /customer-two/another-page并且找不到资源。
我们尝试了以下无济于事:
<!doctype html><html><head>
<script type='text/javascript'>
var base = document.location.pathname.split('/')[1];
document.write('<base href="/' + base + '" />');
</script>...不幸的是,我们的想法很新鲜。任何帮助都会很棒。
慕桂英546537
jeck猫
随时随地看视频慕课网APP
相关分类