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({});
    }
}
配置项
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <script type="text/javascript"> function GetPageSize() { var scrW, scrH; if(window.innerHeight && window.scrollMaxY) { // Mozilla scrW = window.innerWidth + window.scrollMaxX; scrH = window.innerHeight + window.scrollMaxY; } else if(document.body.scrollHeight > document.body.offsetHeight) { // all but IE Mac scrW = document.body.scrollWidth; scrH = document.body.scrollHeight; } else if(document.body) { // IE Mac scrW = document.body.offsetWidth; scrH = document.body.offsetHeight; } var winW, winH; if(window.innerHeight) { // all except IE winW = window.innerWidth; winH = window.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // IE 6 Strict Mode winW = document.documentElement.clientWidth; winH = document.documentElement.clientHeight; } else if (document.body) { // other winW = document.body.clientWidth; winH = document.body.clientHeight; } // for small pages with total size less then the viewport var pageW = (scrW<winW) ? winW : scrW; var pageH = (scrH<winH) ? winH : scrH; return {PageW:pageW, PageH:pageH, WinW:winW, WinH:winH}; } function GetPageScroll() { var x, y; if(window.pageYOffset) { // all except IE y = window.pageYOffset; x = window.pageXOffset; } else if(document.documentElement && document.documentElement.scrollTop) { // IE 6 Strict y = document.documentElement.scrollTop; x = document.documentElement.scrollLeft; } else if(document.body) { // all other IE y = document.body.scrollTop; x = document.body.scrollLeft; } return {X:x, Y:y}; } function main() { var div = document.getElementById("div"); for(var i=0; i<200; i++) { document.body.appendChild(document.createTextNode("Hello, World!")); document.body.appendChild(document.createElement("br")); } var sz = GetPageSize(); alert([sz.PageW,sz.PageH,sz.WinW,sz.WinH].join(", ")); window.scrollTo(0, 1500); var sl = GetPageScroll(); alert([sl.X,sl.Y].join(", ")); } </script> </head> <body onload="main();"> </body> </html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值