angular7中使用插件美化滚动条样式

依赖插件

  • jQuery
  • niceScroll

安装

  • 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"
],

使用

file.component.ts

import { Component, OnInit } from '@angular/core';

// tslint:disable-next-line: no-string-literal
const $ = window['jQuery'];

@Component({
  selector: 'app-file',
  templateUrl: './file.component.html',
  styleUrls: ['./file.component.styl']
})
export class FileComponent implements OnInit {

    constructor() { }

    ngOnInit() {
        this.scrollBar();
    }

    scrollBar() {
        $('.content_wrapper').niceScroll({});
    }
}

配置项


版权声明:本文为yw00yw原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。