我正在尝试将这个Jquery插件添加到我的Angular2项目中。
我已经将文件添加到"src/assets"中,也在index.html中添加了<script src="assets/jquery.twentywenty.js"></script>和declare var twentytwenty: any;
我得到了
jquery.twentytwenty.js:152 Uncaught : jQuery未在jquery.twentytwenty.js:152中定义
也是
TypeError:无法读取属性“二十”的未定义
我在这里错过了什么?
发布于 2018-02-13 14:00:17
我通常会在我的项目中应用以下步骤来使用jquery插件;也许会有所帮助。
1-在jquery (scripts部分)中添加angular-cli.json和plugin文件路径。
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"assets/vendor/plugin/jquery.plugin.js"
]2-在组件中声明jquery变量。
declare let $: any;3-使用插件语法。
(<any>$('#theId')).plugin();https://stackoverflow.com/questions/48768087
复制相似问题