在 main.js 中注入 public 文件夹路径原型
// 前往 public 文件夹的路径
Vue.prototype.$PUBLIC_PATH = process.env.BASE_URL
之后正常使用即可:
getMsg () {
const query = {
url: this.$PUBLIC_PATH + 'data/lottieData.md',
method: 'get',
responseType: 'text'
}
this.$fetchData(query).then(res => {
this.content = res.data
}).catch(error => {
console.log(error)
})
}