安装vue-happy-scroll
npm install vue-happy-scroll --save-dev
注册组件
在main.js文件中引入
// 滚动条 import 'vue-happy-scroll/docs/happy-scroll.css' import HappyScroll from 'vue-happy-scroll' //自定义组件名 Vue.component('happy-scroll', HappyScroll) Vue.use(HappyScroll)
vue组件中使用
<template> <hq-container class="hq">dome //设置颜色和滚动条的尺寸 <happy-scroll color="red" size="3"> <div class="scrollStyle"> <div class="sunScroll"></div> </div> </happy-scroll> </hq-container> </template>