vue慕课网音乐项目手记:33-对base64格式的歌词进行处理

1、安装js-base64

npm  i js-base64 --save

2、使用

import { Base64 } from 'js-base64'
this.lyric = Base64.decode(res.lyric)

3、得到字符串格式的歌词后的处理:

getLyric () {
    if (this.llyric) {
      return new Promise(this.llyric)
    }
    return new Promise((resolve, reject) => {
      getLyric(this.mid).then((res) => {
        if (res.code === ERR_OK) {
          this.lyric = Base64.decode(res.lyric)
          resolve(this.lyric)
        } else {
          reject(new Error('no lyric'))
        }
      })
    })
  }

上面这一块我现在不是很懂,可能和promise有关。后期补上

基于lyric-parse 实现解析歌词

getLyric () {
      this.currentSong.getLyric().then((lyric) => {
        this.currentLyric = new Lyric(lyric)
        console.log(this.currentLyric)
      })
    },


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值