Javascript Angular 6+jQuery+fullpage.js

Javascript Angular 6+jQuery+fullpage.js,javascript,jquery,angular,fullpage.js,Javascript,Jquery,Angular,Fullpage.js,我尝试在没有ngx fullapge的情况下使用fullpage.js,我面临一些与导入相关的问题: 首先,jquery似乎不起作用,即使包已经安装好了 在一个非常简单的AppComponent类定义中,我有: import { Component, OnInit } from '@angular/core'; import * as $ from 'jquery'; import * as fullpagejs from 'fullpage.js'; @Component({ selec

我尝试在没有ngx fullapge的情况下使用fullpage.js,我面临一些与导入相关的问题:

首先,jquery似乎不起作用,即使包已经安装好了

在一个非常简单的AppComponent类定义中,我有:

import { Component, OnInit } from '@angular/core';
import * as $ from 'jquery';
import * as fullpagejs from 'fullpage.js';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ],
})
export class AppComponent  implements OnInit {
  public items = [1, 2, 3];

  public ngOnInit() : void {
    $('#fullpage')
  }
}
使用非常简单的模板:

<div id="fullpage">

  <div class="section" id="landing">
    Landing
  </div>

  <div class="section" *ngFor="let item of items; let i = index" id="document_{{ i }}">
    Document {{ item }}
  </div>

  <div class="section" id="general-information">
    General Information
  </div>

</div>
我的错误如下:

ERROR
Error: $ is not a function
我在这里创建了一个在线项目,重现了这个问题:

如何在这个项目中同时使用jQuery和fullpage.js

[编辑]

jQuery使用来自“jQuery”的import$;但是仍然找不到fullpage.js中的fullpage方法。 我更新了stackblitz:

2018年11月更新:
现在,fullPage.js可用于:

不是一个角度的专家,但是。。。也许您应该在导入窗口对象后在其上声明$

这个怎么样

import { Component, OnInit } from '@angular/core';
import jQuery from 'jquery'; // <--- change here
import * as fullpagejs from 'fullpage.js';

if(!window.$){
    window.$ = jQuery;
}
2018年11月更新:
现在,fullPage.js可用于:

不是一个角度的专家,但是。。。也许您应该在导入窗口对象后在其上声明$

这个怎么样

import { Component, OnInit } from '@angular/core';
import jQuery from 'jquery'; // <--- change here
import * as fullpagejs from 'fullpage.js';

if(!window.$){
    window.$ = jQuery;
}
行import*作为$from'jquery';这绝对正确

确保jquery实际安装在项目中。运行npm安装jquery@latest安装它。然后将其从脚本数组中删除,因为它不属于脚本数组。

行import*作为$from'jquery';这绝对正确


确保jquery实际安装在项目中。运行npm安装jquery@latest安装它。然后将其从脚本数组中删除,因为它不属于脚本数组。

确保目录中存在jquery.fullpage.min.js文件。'/node\u modules/fullpage.js/dist/jquery.fullpage.min.js'

确保目录中存在jquery.fullpage.min.js文件。'/node\u modules/fullpage.js/dist/jquery.fullpage.min.js'

试试看正在向AppComponent添加declare var$:any。现在fullPage.js可用于Angular:尝试向AppComponent添加declare var$:any。现在fullPage.js可用于Angular:尝试重置为最新版本并删除脚本中的路径。。。但同样的old=/@EhouarnPerret请尝试查找package-lock.json文件。jquery在里面吗?它是正确的版本吗?尝试重置为最新版本并删除脚本中的路径。。。但同样的old=/@EhouarnPerret请尝试查找package-lock.json文件。jquery在里面吗?它是正确的版本吗?从“jQuery”以$的形式导入jQuery;是一个语法错误。重命名默认导出甚至没有意义。您给了它一个名称。@LazarLjubenović同意,这可以在导入jQuery中作为$from'jQuery'进行测试;是一个语法错误。重命名默认导出甚至没有意义。你给了它一个名字。@LazarLjubenović同意,这可以在欢迎堆栈溢出中测试!这篇文章似乎是您的第一个答案,其中包含代码。请记住,您可以添加带有标记语法的代码块,这样看起来更好。退房。欢迎来到Stack Overflow!这篇文章似乎是您的第一个答案,其中包含代码。请记住,您可以添加带有标记语法的代码块,这样看起来更好。退房