Lyh*_*Din 3 vue.js vue-component vuex
import { mapState } from 'vuex'
...mapState({
user: (state) =>{
return _.filter(state, data => {
return _.includes(this.allUserIds, data.id)
} )
}
})
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我不会在地图状态下调用 this.allUserIds
不要使用() => {}函数语法,因为它绑定得this太早。
...mapState({
user(state) { // <--- here
return _.filter(state, data => {
return _.includes(this.allUserIds, data.id)
})
}
})
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
477 次 |
| 最近记录: |