ng打包

1.在项目完成后进行项目打包

2.输入ng build后会出现dist打包文件

3.在打包文件中有一个文件index.html文件,改变html中的一个参数

  1. <base href="/">改为<base href="./">
  2. 在app.module中引入 HashLocationStrategy,LocationStrategy
    import {HashLocationStrategy,LocationStrategy} from '@angular/common' 
    在providers  中进行声明   providers: [{provide:LocationStrategy,useClass:HashLocationStrategy}]  注意不要把声明写错,否则会报错
  3.  更改.assest静态资源文件的路径要使用相对路径

猜你喜欢

转载自www.cnblogs.com/rockyjs/p/11910864.html
Ng2