zoukankan      html  css  js  c++  java
  • vue 多个audio播放 一个audio播放其他audio禁止播放

    页面:
            
    <div class="right">
          <audio  :ref="'audio' + index"  :src="item.audioUrl"  @ended="haveEnded"/>
          <div :class="{ active: playIndex == index}"   class="audio-component"   @click="toReadAudio(index)" />
    </div>
     js代码
    toReadAudio (index) {
                let length = this.weekDetail.wordsRepeats.length || 0  // this.weekDetail.wordsRepeats是总共有几条音频数据
                if (length) {
                    for (let i = 0; i < length; i++) {
                        let audioOne = 'audio' + i
                        audioOne = this.$refs[audioOne][0]
                        if (i === index) {
                            if (audioOne.paused) {
                            // 切换播放中的css样式
                                this.playIndex = index
                                audioOne.load()//音频重新加载,重新播放
                                audioOne.play()
                            } else {
                                audioOne.pause()
                                this.playIndex = null
                            }
                        } else {
                            audioOne.pause()
                        }
                    }
                }
            }
  • 相关阅读:
    create-react-app 修改 webpack output.publicPath
    洛谷 P1282 多米诺骨牌 (01背包)
    UVa 1627
    UVa 1626
    UVa 11584
    UVa 11400
    UVa 116
    UVa 1347 Tour (dp)
    树形背包小结
    数据流图题目一
  • 原文地址:https://www.cnblogs.com/lh1998/p/13724278.html
Copyright © 2011-2022 走看看