我正在尝试使用将 Jquery 合并到我的 Angular 8 项目中
var $ = require('jquery');
但是,当我调用此方法时
$(MyControl).tooltip({'title': data.text, html:true});
我得到一个TypeError: $(...).tooltip is not a function
我的 angular.json 脚本部分看起来完全像这样,所以 jquery 在其他两个之前声明
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/@popperjs/core/dist/umd/popper.min.js",
"node_modules/bootstrap/dist/js/bootstrap.min.js"
],
是什么导致了这个错误?
更新 好吧,这只是奇怪所以将这些js文件放在我的angular.json中的样式标题下它可以工作
"styles": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/popper.js/dist/umd/popper.min.js",
"node_modules/bootstrap/dist/js/bootstrap.min.js",
"src/styles.css"
],
将它们放在脚本部分下它不起作用,将它们完全从 angular.json 中删除并且它们不起作用。
它只有两个地方起作用,即直接在 index.html 中作为 CDN 或在样式部分中。
为什么这在样式而不是脚本下起作用有什么押韵或理由吗?
森林海
交互式爱情
随时随地看视频慕课网APP
相关分类