gpt4 book ai didi

javascript - 如何在 ionic 3 中使用 jquery

转载 作者:搜寻专家 更新时间:2023-11-01 04:44:40 24 4
gpt4 key购买 nike

我正在尝试在 ionic 3 中使用 jquery 在 div 中加载外部网站。

TS:

export class HomePage 
{
constructor(public navCtrl: NavController) {
$('#loadExternalURL').load('http://www.google.com');
}
}

HTML:

<ion-content>
<div id="loadExternalURL"></div>
</ion-content>

我在为 ionic 应用程序提供服务时出现黑屏。有什么我想念的吗?有什么建议吗?

最佳答案

我是按照下面的方式做的,

  1. 在您的 IONIC-3 应用程序中安装 Jquery 模块,

    npm install jquery --save

  2. 在 HomePage.ts 中导入 JQuery

    从“jquery”导入 * 作为 $;

  3. 使用 $ 调用 jquery 方法。

我等待方法 ngAfterViewInit 以确保 View 已初始化。

ngAfterViewInit(){
$(document).ready(function(){
alert('JQuery is working!!');
});
}

关于javascript - 如何在 ionic 3 中使用 jquery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46823909/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com