How to use jquery in ionic 3(如何在 ionic 3 中使用 jquery)
问题描述
我正在尝试使用 ionic 3 中的 jquery 在 div 中加载外部网站.
I'm trying to load external website in a div using jquery in ionic 3.
TS:
export class HomePage
{
constructor(public navCtrl: NavController) {
$('#loadExternalURL').load('http://www.google.com');
}
}
HTML:
<ion-content>
<div id="loadExternalURL"></div>
</ion-content>
我在为 ionic 应用程序提供服务时出现黑屏.有什么我想念的吗?有什么建议吗?
I'm getting blank screen on serving the ionic app. Is there anything I'm missing? Any Suggestion?
推荐答案
我是按照下面的方法做的,
I did it in following way,
在您的 IONIC-3 应用中安装 Jquery 模块,
Install Jquery module in your IONIC-3 app,
npm install jquery --save
在 HomePage.ts 中导入 JQuery
Import JQuery in HomePage.ts
从 "jquery" 导入 * 作为 $;
使用$调用jquery方法.
Use $ to call jquery methods.
我等待方法 ngAfterViewInit 以确保视图已初始化.
I wait for method ngAfterViewInit to make sure view is initialized.
ngAfterViewInit(){
$(document).ready(function(){
alert('JQuery is working!!');
});
}
这篇关于如何在 ionic 3 中使用 jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 ionic 3 中使用 jquery


基础教程推荐
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01