Hi FE !
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub
  • 进度条

进度条

进度条组件,通过鼠标拖动来改变进度。progress 直接变化时候会同时触发 change 或 input 事件,因此加一个 mouseDown 的标识,当鼠标不是按下时,只有 progress 变化不触发 change 事件。

<el-slider
  v-model="progress"
  :show-input-controls="false"
  :show-tooltip="false"
  @mousedown.native="handleMouseDown"
  @change="changeProgress" />
handleMouseDown(value) {
    this.mouseDown = true;
    window.onmouseup = () => {
        this.mouseDown = false; window.onmouseup = null;
    };
},

changeProgress(value) {
    const seekTime = (value / 100) * this.sound.duration();
    this.handleUpdateCurrentTime(seekTime);

},
handleUpdateCurrentTime(seekTime) {
    if (this.mouseDown) return; const seek = seekTime || this.sound.seek();
    this.progress = (seek / this.duration) * 100;
},
Edit this page
最近更新: 2025/12/2 01:46
Contributors: qdleader
qdleader
本站总访问量 129823次 | 本站访客数 12人