vue点击按钮滚动到顶部
电梯 (vue-elevator)
A wrapper of elevator.js in Vue.
Vue中的lift.js的包装。
![vue-elevator](https://i-blog.csdnimg.cn/blog_migrate/bdf5921cb132984a9fe50f61db593b15.gif)
安装 (Installation)
npm i -D vue-elevator
用法 (Usage)
For standalone version
对于独立版本
<script src="/dist/vue-elevator.browser.js"></script>
For vue-cli user
对于vue-cli用户
import { VueElevator } from 'vue-elevator'
Vue.component('VueElevator', VueElevator)
样品 (Sample)
<template>
<div id="app">
<VueElevator :word="word" :duration="duration" :mainAudio="mainAudio" :endAudio="endAudio"></VueElevator>
</div>
</template>
export default {
...
data () {
return {
// Replace word, duration, mainAudio and endAudio setting as you want.
// If default is what you like, just don't use related key-value pair and ignore it.
word: "Go to Top",
duration: 4000,
mainAudio: "http://tholman.com/elevator.js/music/elevator.mp3",
endAudio: "http://tholman.com/elevator.js/music/ding.mp3",
}
}
}
翻译自: https://vuejsexamples.com/a-scroll-back-to-top-button-in-vue-js/
vue点击按钮滚动到顶部