Angular6引入Bootstrap等第三方类库无效

版权声明:作者已开启版权声明,如转载请注明转载地址。 https://blog.csdn.net/qq_34829447/article/details/82745140

博主学习Angular时引入第三方类库总是不成功,于是便访问了谷歌和百度,可算找到了解决方法,分享给大家~

1.类库引用路径问题

  • Angular6的命令行工具配置文件从angular-cli.json更名为angular.json,且路径变更
  • 需要对文件中的信息作如下调整
// 调整前
"styles":[
    "styles.css",
    "../node_modules/bootstrap/dist/css/bootstrap.css"
],
"scripts":[
    "../node_modules/jquery/dist/jquery.js",
    "../node_modules/bootstrap/dist/js/bootstrap.js"
]
// 调整后
"styles":[
    "src/styles.css",
    "node_modules/bootstrap/dist/css/bootstrap.css"
],
"scripts":[
    "node_modules/jquery/dist/jquery.js",
    "node_modules/bootstrap/dist/js/bootstrap.js"
]
  • 修改后需要重启服务才可以生效

2.注意事项

  • 修改后要重启服务才可以生效
  • 请务必确认修改的是build下的scripts和styles,否则一样是不生效的~

猜你喜欢

转载自blog.csdn.net/qq_34829447/article/details/82745140