我正在尝试在spfx angular应用程序中使用jquery滑块,但是在运行时出现错误
在config.json文件中添加了滑块文件路径
未捕获(承诺)错误 在t [作为构造函数](sp-webpart-workbench-assembly_zh-cn_02f82384d156c9ae5002115e76d3af48.js:4) 在新时间(sp-webpart-workbench-assembly_zh-cn_02f82384d156c9ae5002115e76d3af48.js:20) 在Function.e.buildErrorWithVerboseLog(sp-webpart-workbench-assembly_zh-cn_02f82384d156c9ae5002115e76d3af48.js:20) 在Function.e.buildLoadComponentError(sp-webpart-workbench-assembly_zh-cn_02f82384d156c9ae5002115e76d3af48.js:20) 在sp-webpart-workbench-assembly_zh-cn_02f82384d156c9ae5002115e76d3af48.js:20
app.component.ts文件
import { Component, OnInit,Inject,AfterViewInit, ElementRef} from '@angular/core';
import { CommonService } from '../common.service';
import {IWebPartContext} from '@microsoft/sp-webpart-base';
//import * as $ from 'jquery';
declare var jQuery:any;
import './coin-slider.js';
@Component({
selector: 'my-spfx-app',
template: require("./app.component.html") as string,
})
export class AppComponent implements AfterViewInit {
public name: string = '';
public context:IWebPartContext;
todayDate;
userList = [];
newsData = [];
searchText = '';
sortField = '';
orderBy = 'DESC';
siteUrl = '';
elementRef: ElementRef;
constructor(@Inject(CommonService)private myservice: CommonService,
@Inject(ElementRef) elementRef: ElementRef) {
this.elementRef = elementRef;
}
public ngAfterViewInit() {
let data : any;
let dataList : any;
this.context= window["webPartContext"];
this.siteUrl = this.context.pageContext.site.absoluteUrl;
jQuery(this.elementRef.nativeElement).find('#coin-slider').coinslider({
navigation: false,
delay: 2000,
effect: 'rain',
});
}
}
如何解决错误并实现jquery滑块?