javascript - 如何在 Angular 9 中正确安装预建模板
问题描述
我正在尝试在我的 Angular 9 应用程序中使用免费模板,但多次失败。尽管进行了多次尝试,但滑块、产品和主页横幅并未出现。我建议您下载一次模板并检查文件夹目录以便更好地理解。
1)我尝试通过 NPM 安装 js 和 CSS 文件,然后在 angular.json 脚本和样式数组中调用所需的文件,但有些包不起作用,尽管它们中的大多数都可以。
2) 通过 src/assets/js/bootstrap.min.js 和 src/assets/css/bootstrap.min.css 等 js 和 CSS 文件夹调用 js 和 CSS 文件,但它没有帮助并产生很多错误。
3)解压缩源文件夹中的文件,然后像 src/assets/source/bootstrap-4.4.1-dist/js/bootstrap.min.js 一样调用它们,但这也返回了一些错误。
到目前为止,我使用 NPM 包并在 angular.json 中调用 then 获得了最好的结果,但 jQuery 仍然没有按预期工作。
角.json:
"styles": [
"src/assets/sass/style.scss",
"./node_modules/bootstrap/dist/css/bootstrap.min.css",
"./node_modules/slicknav/dist/slicknav.min.css",
"./node_modules/elegant-icons/style.css",
"./node_modules/font-awesome/css/font-awesome.min.css",
"./node_modules/jquery-ui-dist/jquery-ui.min.css",
"./node_modules/jquery-nice-select/css/nice-select.css",
"./node_modules/owl.carousel/dist/assets/owl.carousel.min.css",
"src/assets/css/style.css",
"src/styles.scss"
],
"scripts": [
"./node_modules/jquery/dist/jquery.min.js",
"./node_modules/bootstrap/dist/js/bootstrap.min.js",
"./node_modules/jquery-ui-dist/jquery-ui.min.js",
"./node_modules/jquery-nice-select/js/jquery.nice-select.min.js",
"./node_modules/slicknav/dist/jquery.slicknav.min.js",
"./node_modules/mixitup/dist/mixitup.min.js",
"./node_modules/owl.carousel/dist/owl.carousel.min.js",
"src/assets/js/main.js"
]
问题:
解决方案
尝试在index.html文件的 header 标签中添加 jQuery CDN,然后重新加载页面。
索引.html
<head>
...
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
...
</head>
推荐阅读
- dart - 获取 Google 登录验证和刷新令牌
- c# - SYNONYM 的 INSERT 语句在 SQL Server 中失败;有任何想法吗?
- machine-learning - 深度学习日志似然
- css - 如何使用伪元素选择以 foo 结尾的域的链接?
- javascript - 添加“悬停”与“滚动”相同的功能
- sql-server - 从 SQL Server 获取所有用户定义的对象
- javascript - Mongoose 更新多个子文档
- mysql - 在不同的表中使用相同的字段名然后进行联合查询有什么问题吗?
- python - SQLAlchemy:使用给定数组中的元素查询数据库列
- angularjs - md-tabs 不显示滚动或分页