bootstrap.css在angular2通用中不起作用
问题描述:
即时通讯使用angular2 universal,
在index.html头文件中添加bootstrap.min.css,但无法正常显示404 err,只能使用@Component中的方法styleUrls:[' bootstrap.css']可以工作。为什么以及如何解决这个问题?bootstrap.css在angular2通用中不起作用
答
使用link rel =“stylesheet”href =“assets/bootstrap.min.css并复制src/assets文件中的css文件可以解决这个问题,因为在server.ts文件中app.use('/ assets', express.static(path.join(__ dirname,'assets'),{maxAge:30}))
当然,我将它添加到index.html中,并且我没有编写styleUrls:['bootstrap.css']在@组件中,但无法工作,所以我只能使用styleUrls中写入的方法,但我不会使用第二种方法,请考虑angular2通用环境。 – percinor