简体   繁体   English

在Ionic index.html中包含jQuery的位置

[英]Where to include jQuery in Ionic index.html

I have a strange problem here. 我这里有一个奇怪的问题。

I am working on a Ionic (AngularJS) project and using jQuery in one of my controllers, so need to add the reference to it in index.html 我正在研究Ionic(AngularJS)项目,并在其中一个控制器中使用jQuery,因此需要在index.html中添加对其的引用

If I add reference like this - 如果我添加这样的参考-

<!-- jQuery js -->
<script type="text/javascript" src="lib/jquery/jquery-2.1.3.min.js"></script>
<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>

then, I get below error from one of the views - 然后,我从其中一种观点得到了错误-

Error: [$compile:ctreq] Controller 'ionTabs', required by directive 'ionTabNav', can't be found!

But, If I add reference like this - 但是,如果我添加这样的引用-

<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>
<!-- jQuery js -->
<script type="text/javascript" src="lib/jquery/jquery-2.1.3.min.js"></script>

then, I get below error from another one of the controllers, which was the reason I included jQuery in the first place - 然后,我从另一个控制器收到错误消息,这就是我首先包含jQuery的原因-

Error: [jqLite:nosel] Looking up elements via selectors is not supported by jqLite! 

Not sure how to resolve this? 不确定如何解决此问题? I need to get both functionalities working. 我需要使两个功能同时工作。

Thanks in advance. 提前致谢。

Looks like this is a conflict between ionic and certain versions of jQuery . 看起来这是ionic和某些版本的jQuery之间的冲突。 https://github.com/driftyco/ionic/issues/1976 - switching the version of jQuery you are using should resolve. https://github.com/driftyco/ionic/issues/1976-可以解决切换使用的jQuery版本的问题。

I have a feeling that the problem here is not with a conflict between ionic (per se) and jQuery, but an issue with Angular and jQuery. 我感觉这里的问题不是与ionic(本身)和jQuery之间的冲突,而是与Angular和jQuery有关的问题。

Angular comes with a jQlite version of jQuery and that's probably what is conflicting. Angular带有jQuery的jQlite版本,这可能是矛盾的。 You might get some more information from this post on the Ionic Forum . 您可能会在Ionic论坛上从此帖子中获得更多信息。

Sorry I can't be more helpful, I'm only just starting out on my ionic adventures myself. 抱歉,我不能提供更多帮助,我只是开始自己的离子冒险。

You need to use jQuery Lite. 您需要使用jQuery Lite。 Read more at https://docs.angularjs.org/api/ng/function/angular.element https://docs.angularjs.org/api/ng/function/angular.element上阅读更多内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ReactJS + Redux:在哪里正确包含CSS和index.html文件? - ReactJS + Redux: Where to properly include CSS and index.html files? AngularJS:将菜单作为部分包含在index.html中 - AngularJS: Include menu as partial in index.html 在哪里包含index.html <head/> 类帮助器函数放入ReactJS组件? - Where to include index.html <head/> class helper functions into ReactJS Component? Webpack - 如何包含。html 片段进入索引。html 实时重新加载? - Webpack - How to include .html fragments into index.html with live reloading? ionic 2如何在index.html中使用常量变量的声明? - ionic 2 how to use constants variable's declare in index.html? 从javascript index.html发布离子事件 - Publish an Ionic Event from javascript index.html angular cli包含/排除index.html中的脚本,具体取决于环境 - angular cli include/exclude scripts in index.html depending on the environment AngularJS App:如何将.js文件包含到index.html中 - AngularJS App: How to include .js files into index.html index.html重定向到哪里? [Moodle Mobile] [Javascript] - Where does the index.html redirect to? [Moodle Mobile][Javascript] 在哪里将index.html放在Kotlin-js项目中? - Where to put index.html in a Kotlin-js project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM