[英]Property 'ripples' does not exist on type 'JQuery<HTMLElement>'. in angular component
I'm trying to implement a jquery function on angular but terminal is returning the following error:我正在尝试在 angular 上实现 jquery 函数,但终端返回以下错误:
Property 'ripples' does not exist on type 'JQuery<HTMLElement>'类型 'JQuery<HTMLElement>' 上不存在属性 'ripples'
While on my console I'm getting the following error: ERROR ReferenceError: $ is not defined在我的控制台上,我收到以下错误: ERROR ReferenceError: $ is not defined
Here is my code snippet这是我的代码片段
import { Component, OnInit } from '@angular/core';
import * as $ from 'jquery';
import 'jqueryui';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {
constructor() { }
ngOnInit() {
$(document).ready(function() {
$('.image').ripples('show');
});
}
}
You have to declare $ as following ,你必须声明$如下,
declare var $;
instead of代替
import * as $ from 'jquery';
UPDATED更新
Update your angular.json
file更新你的angular.json
文件
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
//Here ripple module path
],
This will solve your error -> $ not declared and also of ripple .这将解决您的错误 - > $ not created以及Ripple 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.