依赖插件
jQueryniceScroll安装
cnpm i jquery --save
cnpm install jquery.nicescroll
引入
angular.json
"scripts": ["node_modules/_jquery@3.3.1@jquery/dist/jquery.min.js","node_modules/_jquery.nicescroll@3.7.6@jquery.nicescroll/dist/jquery.nicescroll.min.js"],
使用
ponent.ts
import { Component, OnInit } from '@angular/core';// tslint:disable-next-line: no-string-literalconst $ = window['jQuery'];@Component({selector: 'app-file',templateUrl: './ponent.html',styleUrls: ['./ponent.styl']})export class FileComponent implements OnInit {constructor() { }ngOnInit() {this.scrollBar();}scrollBar() {$('.content_wrapper').niceScroll({});}}