我已将外部脚本包含在scripts属性中的.angular-cli.json文件中,即
`
"scripts": [
"../src/assets/plugins/jquery/jquery.min.js",
"../src/assets/plugins/popper/popper.min.js",
"../src/assets/plugins/jquery-blockui/jquery.blockui.min.js",
"../src/assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js",
"../src/assets/plugins/datatables/jquery.dataTables.min.js",
"../src/assets/plugins/datatables/plugins/bootstrap/dataTables.bootstrap4.min.js",
"../src/assets/js/pages/table/table_data.js",
"../src/assets/js/app.js",
"../src/assets/js/layout.js",
"../src/assets/js/theme-color.js",
"../src/assets/plugins/material/material.min.js",
"../src/assets/js/pages/ui/animations.js",
"../src/assets/plugins/bootstrap/js/bootstrap.min.js",
"../src/assets/plugins/bootstrap-inputmask/bootstrap-inputmask.min.js",
"../src/assets/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js",
"../src/assets/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker-init.js",
"../src/assets/plugins/jquery-tags-input/jquery-tags-input.js",
"../src/assets/plugins/jquery-tags-input/jquery-tags-input-init.js",
],`
启动角度应用程序时,将加载所有脚本。但是当我切换到另一个页面时,脚本不会加载。
答案 0 :(得分:0)
Angular适用于单页应用,从技术上讲,只要您正确使用路由器,就不会在ng应用中切换页面。所有脚本都捆绑在一起,由Webpack添加到index.html,并且只在加载index.html时加载一次。