vue中methods有值但是传到mounted却是undefined,这是为什么 该怎么办?
mounted() {
this.$nextTick(() => {
getPeixianMapData().then(res => {
let top10Datas = this.getPeixianMapValue()
console.log('top10Datas', top10Datas)
this.initChart(top10Datas)
})
})
},
methods: {
getPeixianMapValue() {
getPeixianMapValue(0, 10000, {}).then(res => {
let rd = res.data.content
function compare(property){
return function(a,b){
let value1 = a[property];
let value2 = b[property];
return value2 - value1;
}
}
let sortData = rd.sort(compare('value'))
let top10Data = []
for (let i = 0; i < 10; i++) {
top10Data.push(sortData[i])
}
console.log('top10', top10Data)
return top10Data
})
},
......
}