asyncData and computed not support,has error!
Closed this issue · 1 comments
AaronChen2012 commented
like this:
export default {
name: 'show-data',
asyncData: {
list() {
return new Promise((resolve, reject) => {
setTimeout(_ => {
resolve([
{id:0,name:"衣服",type:0},
{id:1,name:"券",type:1}
])
}, 1000);
})
},
},
computed: {
type0Data(){
return this.list.filter(function (m) {
return m.type===0
})
},
}
}
kamijin-fanta commented
@AaronChen2012 List
is undefined until promise is resolved. It may be solved by specifying a default value. please see the README.
export default {
name: 'show-data',
asyncData: {
listDefault: [],
list() {
return new Promise((resolve, reject) => {
setTimeout(_ => {
resolve([
{id:0,name:"衣服",type:0},
{id:1,name:"券",type:1}
])
}, 1000);
})
},
},
}