TS1005: ‘,‘ expected.

bash 复制代码
[0]  ERROR  Failed to compile with 3 errors15:04:40
[0] 
[0]  error  in /Users/dgq/Downloads/cursor/spid-admin/src/views/tools/fake-strategy/components/invite-code-list.vue.ts
[0] 
[0] [tsl] ERROR in /Users/dgq/Downloads/cursor/spid-admin/src/views/tools/fake-strategy/components/invite-code-list.vue.ts(139,13)
[0]       TS1005: ',' expected.
[0] 
[0]  @ ./src/views/tools/fake-strategy/components/invite-code-list.vue?vue&type=script&lang=ts& 1:0-379 1:395-398 1:400-776 1:400-776
[0]  @ ./src/views/tools/fake-strategy/components/invite-code-list.vue
[0]  @ ./node_modules/cache-loader/dist/cjs.js??ref--15-0!./node_modules/babel-loader/lib!./node_modules/ts-loader??ref--15-2!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/tools/fake-strategy/components/config-form2.vue?vue&type=script&lang=ts&
[0]  @ ./src/views/tools/fake-strategy/components/config-form2.vue?vue&type=script&lang=ts&
[0]  @ ./src/views/tools/fake-strategy/components/config-form2.vue
[0]  @ ./node_modules/cache-loader/dist/cjs.js??ref--15-0!./node_modules/babel-loader/lib!./node_modules/ts-loader??ref--15-2!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/tools/fake-strategy/index.vue?vue&type=script&lang=ts&
[0]  @ ./src/views/tools/fake-strategy/index.vue?vue&type=script&lang=ts&
[0]  @ ./src/views/tools/fake-strategy/index.vue
[0]  @ ./src/router/index.ts
[0]  @ ./src/main.ts
[0]  @ multi (webpack)-dev-server/client?http://192.168.1.105:9527&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.ts
[0] 
[0]  error  in /Users/dgq/Downloads/cursor/spid-admin/src/views/tools/fake-strategy/components/invite-code-list.vue.ts
[0] 
[0] [tsl] ERROR in /Users/dgq/Downloads/cursor/spid-admin/src/views/tools/fake-strategy/components/invite-code-list.vue.ts(146,13)
[0]       TS1005: ',' expected.
[0] 
[0]  @ ./src/views/tools/fake-strategy/components/invite-code-list.vue?vue&type=script&lang=ts& 1:0-379 1:395-398 1:400-776 1:400-776
[0]  @ ./src/views/tools/fake-strategy/components/invite-code-list.vue
[0]  @ ./node_modules/cache-loader/dist/cjs.js??ref--15-0!./node_modules/babel-loader/lib!./node_modules/ts-loader??ref--15-2!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/tools/fake-strategy/components/config-form2.vue?vue&type=script&lang=ts&
[0]  @ ./src/views/tools/fake-strategy/components/config-form2.vue?vue&type=script&lang=ts&
[0]  @ ./src/views/tools/fake-strategy/components/config-form2.vue
[0]  @ ./node_modules/cache-loader/dist/cjs.js??ref--15-0!./node_modules/babel-loader/lib!./node_modules/ts-loader??ref--15-2!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/tools/fake-strategy/index.vue?vue&type=script&lang=ts&
[0]  @ ./src/views/tools/fake-strategy/index.vue?vue&type=script&lang=ts&
[0]  @ ./src/views/tools/fake-strategy/index.vue
[0]  @ ./src/router/index.ts
[0]  @ ./src/main.ts
[0]  @ multi (webpack)-dev-server/client?http://192.168.1.105:9527&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.ts
[0] 
[0]  error  in /Users/dgq/Downloads/cursor/spid-admin/src/views/tools/fake-strategy/components/invite-code-list.vue.ts
[0] 
[0] [tsl] ERROR in /Users/dgq/Downloads/cursor/spid-admin/src/views/tools/fake-strategy/components/invite-code-list.vue.ts(179,17)
[0]       TS1005: ',' expected.
[0] 
[0]  @ ./src/views/tools/fake-strategy/components/invite-code-list.vue?vue&type=script&lang=ts& 1:0-379 1:395-398 1:400-776 1:400-776
[0]  @ ./src/views/tools/fake-strategy/components/invite-code-list.vue
[0]  @ ./node_modules/cache-loader/dist/cjs.js??ref--15-0!./node_modules/babel-loader/lib!./node_modules/ts-loader??ref--15-2!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/tools/fake-strategy/components/config-form2.vue?vue&type=script&lang=ts&
[0]  @ ./src/views/tools/fake-strategy/components/config-form2.vue?vue&type=script&lang=ts&
[0]  @ ./src/views/tools/fake-strategy/components/config-form2.vue
[0]  @ ./node_modules/cache-loader/dist/cjs.js??ref--15-0!./node_modules/babel-loader/lib!./node_modules/ts-loader??ref--15-2!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/tools/fake-strategy/index.vue?vue&type=script&lang=ts&
Webpack: Starting ...

1、源代码

ts 复制代码
  private async handleLock(row: any) {
    const newIsLocked = row.isLocked === 0 ? 1 : 0
    const newStatus = newIsLocked === 0
      ? InviteCodeStatus.EFFECTIVE.name
      : InviteCodeStatus.LOCKED.name

    this.$confirm(
      `确定要${row.isLocked === 0 ? '锁定' : '解锁'}该邀请码吗?`,
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }
    )
      .then(async() => {
        try {
          console.log('请求参数:', {
            inviteCodeId: row.id,
            statusName: newStatus
            isLocked: newIsLocked, // 添加 isLocked 参数
          })

          // 调用后端的更新状态接口
          const response = await updateInviteCodeStatus({
            inviteCodeId: row.id,
            statusName: newStatus
            isLocked: newIsLocked, // 添加 isLocked 参数
          })

          console.log('response.data:', response.data)
          console.log('typeof response.data', typeof response.data)

          if (response && response.data && typeof response.data === 'object' && 'status' in response.data) {

            const status = response.data.status
            const isLocked = response.data.isLocked

            // 调试步骤 1:打印状态值
            console.log('状态值:', status)
            console.log('后端返回的isLocked值:',isLocked)

            // 调试步骤 2:检查状态映射
            let statusObj
            try {
              statusObj = InviteCodeStatus.fromValue(status)
              console.log('映射后的状态:', statusObj)
            } catch (e) {
              console.error('状态映射错误:', e)
              this.$message.error('状态映射错误,请联系管理员')
              return
            }

            // 更新本地数据
            const index = this.tableData.findIndex(item => item.id === row.id)
            if (index !== -1) {
              this.$set(this.tableData, index, {
                ...this.tableData[index],
                // isLocked: newIsLocked,
                status: status // 使用后端返回的 status 值
                isLocked: isLocked, // 使用后端返回的isLocked
              })
              console.log('更新后的行数据:', this.tableData[index])
            }

            this.$message.success(`${newIsLocked === 0 ? '解锁' : '锁定'}成功`)

            // 选择性地重新拉取数据,根据实际需求
            // await this.fetchInviteCodeList();
          } else {
            this.$message.error('更新失败')
          }
        } catch (error) {
          console.error('更新邀请码状态失败:', error)
          console.error('错误详情:', error.response || error.message)
          this.$message.error('更新邀请码状态失败:未知错误')
        }
      })
      .catch(() => { })
  }

2、修改后的代码

ts 复制代码
          console.log('请求参数:', {
            inviteCodeId: row.id,
            statusName: newStatus,
            isLocked: newIsLocked, // 添加 isLocked 参数
          })
ts 复制代码
          // 调用后端的更新状态接口
          const response = await updateInviteCodeStatus({
            inviteCodeId: row.id,
            statusName: newStatus,
            isLocked: newIsLocked, // 添加 isLocked 参数
          })

缺失了逗号,导致 isLocked: newIsLocked 被认为是 statusName 的值,进而产生语法错误。

ts 复制代码
              this.$set(this.tableData, index, {
                ...this.tableData[index],
                // isLocked: newIsLocked,
                status: status, // 使用后端返回的 status 值
                isLocked: isLocked, // 使用后端返回的isLocked
              })

在对象字面量中漏写了逗号


相关推荐
软件技术NINI4 分钟前
娃娃店html+css 4页
前端·css·html
VX:Fegn08958 分钟前
计算机毕业设计|基于springboot + vue乡村振兴服务系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·课程设计
wordbaby11 分钟前
TanStack Router 路径参数(Path Params)速查表
前端
梵尔纳多23 分钟前
Electron 主进程和渲染进程通信
javascript·arcgis·electron
盟接之桥1 小时前
盟接之桥--说制造:从“找缝隙”到“一万米深”——庖丁解牛式的制造业精进之道
大数据·前端·数据库·人工智能·物联网·制造
巴拉巴拉~~1 小时前
Flutter 通用滑块组件 CommonSliderWidget:单值 / 范围 + 刻度 + 标签 + 样式自定义
开发语言·前端·javascript
期待のcode1 小时前
验证码实现
java·vue.js
韭菜炒大葱1 小时前
现代前端开发工程化:Vue3 + Vite 带你从 0 到 1 搭建 Vue3 项目🚀
前端·vue.js·vite
老华带你飞1 小时前
志愿者服务管理|基于springboot 志愿者服务管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·后端·spring
有意义1 小时前
从 useState 到 useEffect:React Hooks 核心机制详解
javascript·react.js·前端工程化