首页 > 解决方案 > Angular 6 magnificPopup 中的 jQuery 不是函数

问题描述

我正在尝试使用 jQuery magnificPopup并在控制台中出现错误。

$(...).magnificPopup 不是函数

我包括这个:

“脚本”:[“../node_modules/jquery/dist/jquery.min.js”]

在 angular.json 文件中,我的控制器如下所示:

import {Component, AfterViewInit} from '@angular/core';
declare var $: any;
@Component({
    selector: 'app-header',
    templateUrl: './header.component.html',
    styleUrls: ['./header.component.less'],
})
export class HeaderComponent implements AfterViewInit {
    constructor() {

    }

    ngAfterViewInit() {
        debugger;
        $('#inline-popups').magnificPopup({ // says magnificPopup is not a function
            delegate: 'a',
            removalDelay: 500,
            callbacks: {
            beforeOpen: function() {
                    this.st.mainClass = this.st.el.attr('data-effect');
                }
            },
            midClick: true
        });
    }
}

标签: jqueryangular6magnific-popup

解决方案



推荐阅读