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)
})
},