【发布时间】:2022-01-22 01:08:06
【问题描述】:
我无法在 nuxt 的计算属性中使用 lodash 进行过滤。
我从 API 获取博客列表,在 Vue 调试器中出现以下错误
(评估时出错)
我要过滤已删除状态为false的数据列表。
这里是 JS
<script>
import { _ } from 'lodash'
export default {
data() {
return {
data: [
{
deleted: {
status: false,
date: '2021-12-20T10:18:33.231Z',
},
blogUID: '*********',
title: 'Guide To Visiting Inflatable Island In The New Normal',
},
{
deleted: {
status: false,
date: '2021-12-20T10:18:33.231Z',
},
blogUID: '*********',
title: '24 Best Places to Celebrate New Year in India',
},
{
deleted: {
status: false,
date: '2021-12-20T10:18:33.231Z',
},
blogUID: '*********',
title: 'Top Things to Do in Dubai',
},
{
deleted: {
status: true,
date: '2021-12-20T10:18:33.231Z',
},
blogUID: '*********',
title: 'Best Places to Celebrate New Year 2022',
},
],
}
},
computed: {
activeData() {
return _.filter(this.data, { 'deleted.status': false })
},
},
}
</script>
【问题讨论】: