Ionic:ReferenceError:$未定义 [英] Ionic: ReferenceError: $ is not defined
本文介绍了Ionic:ReferenceError:$未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到错误ReferenceError:$未在我的离子应用程序中定义。
I'm getting the error ReferenceError: $ is not defined on my ionic application.
我正在尝试从我的json文件中打开系统浏览器中的链接。
I'm trying to open links in the systems browser from my json file.
以下是代码:
$timeout(function () {
$('.ex-link').click(function () {
var url = $(this).attr('href');
window.open(encodeURI(url), '_system', 'location=yes');
return false;
})
})
获得错误的行是:
$('.ex-link').click(function () {
推荐答案
Angular将使用jqLite。但是你可以在Angular.js之前包含jQuery.js并通过jQuery使Angular替换jqLite。$将被定义。
Angular will use jqLite. However you can include jQuery.js before Angular.js and make Angular replace jqLite by jQuery. $ will be difined.
在包含AngularJS之前包含jQuery,
Include jQuery before including AngularJS as,
<!-- Add jQuery from -->
<script type="text/javascript" src="jquery.js"></script>
<!-- And then AngularJS -->
<script type="text/javascript" src="angularjs.js"></script>
这篇关于Ionic:ReferenceError:$未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文