【发布时间】:2020-02-11 13:49:51
【问题描述】:
我正在尝试在 Angular 上实现 jquery 函数,但终端返回以下错误:
类型“JQuery
”上不存在属性“涟漪”
在我的控制台上出现以下错误:ERROR ReferenceError: $ is not defined
这是我的代码 sn-p
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');
});
}
}
【问题讨论】:
-
ripples()不是标准的 jQuery 方法。您需要将包含它的库包含到页面中 -
我安装了 npm i jquery.ripples
-
您还需要将它包含在页面的脚本中。
-
@phuzi 是的,我做到了“样式”:[“node_modules/jquery.ripples/dist/jquery.ripples-min.js”]
-
不确定
styles对于通常包含为<script>的内容是否正确