1.首先使用npm命令安装jQuery
npm install jQuery
2.然后在index.html 引入jquery文件
<!-- 可以使用本地文件 -->
<script type="text/javascript" src="assets/js/jquery.min.js"></script>
3.在要用到的components组件中使用:
import { Component, OnInit, Input } from '@angular/core';
import { AlertController } from '@ionic/angular';
import { ModalController } from "@ionic/angular";
import { ActionSheetService } from "ng-zorro-antd-mobile";
declare let $: any;
@Component({
selector: 'app-test-name',
templateUrl: './test-name.component.html',
styleUrls: ['./test-name.component.scss'],
})
export class testNameOptComponent implements OnInit {
constructor(
private alert: AlertController,
private eventService: EventService,
public modalController: ModalController
) { }
@Input() tagData: any;
isshowhistory = false; // 判断展示还是隐藏
sessionId: string;
receiveList: any;
isDataShow = false;
ifget: any;
foldimg: any;
pageSize: 0;
ngOnInit() {
}
showclick() {
this.isshowhistory = !this.isshowhistory;
// const h = $(window).scrollTop();
if (this.isshowhistory === true) {
this.foldimg = "../../../assets/img/foldup.png";
// $('#id-presales-history-panel').fadeIn();
// $('#id-presales-history-panel').animate({ height: "auto" });
// $("#id-presales-history-panel").slideDown();
$("#id-presales-history-panel").slideToggle("slow");
// $('html,body').animate({ "scrollTop": h + 800 }, 800);
// localStorage.setItem('nav1ScrollToBottomTag', '50');
// this.eventService.eventEmit.emit('nav1ScrollToBottom', '1');
} else {
// $('#id-presales-history-panel').fadeOut();
// $("#id-presales-history-panel").slideUp();
$("#id-presales-history-panel").slideToggle("slow");
// $('html,body').animate({ "scrollTop": h + 800 }, 800);
// localStorage.setItem('nav1ScrollToBottomTag', '50');
// this.eventService.eventEmit.emit('nav1ScrollToBottom', '1');
// this.foldimg = "../../../assets/img/folddown.png";
}
console.log(this.isshowhistory);
}
}