jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery-ui – 如何使用@ types / jqueryui和angular2(typescript)大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在我的角度应用程序中使用 jqueryui

我可以像这样导入jquery

import * as $from 'jquery';

但是如何从中导入’@ types / jqueryui’
https://www.npmjs.com/package/@types/jqueryui

由于jqueryui是一个接口,我无法导入它

我如何使用jquery

export class JqueryUIIntegrationComponent implements AfterViewInit{
        @ViewChild('jqueryElement') el:ElementRef;
        constructor() {
        }

    ngAfterViewInit() {
        console.log(this);
        $(this.el.nativeElement).slideUp(4000).slideDown(5000); // jquery function
        $(this.el.nativeElement).draggable(); //Since jqueryui is not imported this will not work
    }
}

解决方法

解决方法:(不是@ types / jqueryui的解决方案)

您可以使用@ types / jqueryui进行输入/自动完成支持.

根HTML:

导入jquery和jquery UI js文件

<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>

零件:

在您的组件声明中

declare var $:any;

像这样在课堂上使用它

export class JqueryUIIntegrationComponent implements AfterViewInit {
    @ViewChild('jqueryElement') el:ElementRef;
    constructor() {
    }

    ngAfterViewInit() {
        console.log(this);
        $(this.el.nativeElement).draggable(); //same old style
    }
}

注意:欢迎通过@ types / jqueryui(正确方式)获得任何原生支持.如果您找到任何解决方案,请告诉我.

大佬总结

以上是大佬教程为你收集整理的jquery-ui – 如何使用@ types / jqueryui和angular2(typescript)全部内容,希望文章能够帮你解决jquery-ui – 如何使用@ types / jqueryui和angular2(typescript)所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。