• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

mandyGuan12

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

报错TypeError: Cannot read properties of undefined (reading 'filter')

浏览器报错:TypeError: Cannot read properties of undefined (reading 'filter')

一开始写定了一个list数组一直没出错,后面换成pinia的数据就出问题了

原代码:

const list = computed(() => {
  store.state.menuList
})

const noChildren = computed(() => list.value.filter(item => !item.children))

解决:
computed里放的store.state.menuList多环绕了一对大括号,于是它说我不能用filter方法。

修改后的代码:

const list = computed(() => store.state.menuList)

const noChildren = computed(() => list.value.filter(item => !item.children))

要么在里面return出去也行

posted on 2024-08-30 16:19  番茄仔Mandy  阅读(260)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3