angular – 与webpack的动态基础href链接
发布时间:2020-12-17 17:26:57 所属栏目:安全 来源:网络整理
导读:当我转移到Angular-CLI时,我刚从systemjs转移到webpack. 它曾经工作但它不再. 这是我有的: 在我的index.html中 script type='text/javascript' var base = document.location.pathname.split('/')[1]; document.write('base href="/' + base + '" /');/scri
当我转移到Angular-CLI时,我刚从systemjs转移到webpack.
它曾经工作但它不再. 这是我有的: 在我的index.html中 <script type='text/javascript'> var base = document.location.pathname.split('/')[1]; document.write('<base href="/' + base + '" />'); </script> 而且我还在添加的几个js文件的根部添加了一个“/”. 现在我在webpack上,这些文件是从其他地方加载的,我不能再添加这个“/”了. 我已经看到我必须更新webpack.config.js文件中的内容,但angular-cli家伙已经决定将它放在他们的模块中,而不是像往常一样放在项目根目录上. 有没有一个好方法呢? 解决方法
# Sets base tag href to /myUrl/ in your index.html ng build --base-href /myUrl/ ng build --bh /myUrl/ https://github.com/angular/angular-cli#base-tag-handling-in-indexhtml (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |