Uba*_*zad 9 javascript django typescript angular-cli angular
我有一个现有的django项目,我在/ static/path上提供静态文件.我正在将应用程序的一部分迁移到angular2,成为该站点的特定移动版本.
添加<base href="/">到index.html加载静态文件www.example.com/main.js在这里得到404.添加<base href="/static/">到index.html正确加载静态文件,但是当应用程序引导时,它会将url更改为/ static /(我正在使用路由器),尽管我的url应该是/ order /.
有没有办法使用base href作为/但使用angular-cli为脚本和样式文件添加前缀
使用版本 ng --version
@angular/cli: 1.0.0-rc.0
node: 6.9.1
os: win32 x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
@angular/cli: 1.0.0-rc.0
@angular/compiler-cli: 2.4.9
Run Code Online (Sandbox Code Playgroud)
Har*_*ngh 14
您可以使用--deploy-url为生成的静态文件的路径添加前缀.ng build --deployUrl /static/.它会/static/在生成的index.html中为js文件的路径添加前缀,如下所示:
<script type="text/javascript" src="/static/inline.bundle.js"></script>
Run Code Online (Sandbox Code Playgroud)
来自帮助文档:
--deploy-url (String) URL where files will be deployed.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5292 次 |
| 最近记录: |