和后端同学进行了对接,结果出现了问题
排查之后才发现是异步传值的问题
原来部分代码是这样
mounted () {
……
this.getRawData1()
……
}
getRawData1 () {
this.$axios
// 传递用户名和密码
.get('/daily')
.then(response => { this.RawData = response })
.catch(function (error) { // 请求失败处理
console.log(error)
})
},
发现response输出的值正常,证明后端返回的数据没问题
但 this.getRawData1() 调用后 this.RawData 值没有更新
排查后发现是异步传值造成的
改为
async mounted () {
await this.getRawData1().then(res => {
this.RawData = res
})
}
async getRawData1 () {
var data = []
return this.$axios
// 传递用户名和密码
.get('/daily')
.then(response => {
data = response.data
console.log(data)
return data
})
.catch(function (error) { // 请求失败处理
console.log(error)
})
}
问题解决,但数据都加进去以后,效果更丑了 (  ̄へ ̄ )!
接下来将修改配置项达到预估效果