uni-app 使用schema2code生成uniCloud admin页面,点击删除按钮时提示.remove is not a function

uni-app 使用schema2code生成uniCloud admin页面,点击删除按钮时提示.remove is not a function

产品分类:uniCloud/App

操作步骤:

  • 用DB Schema创建表结构,然后用schema2code创建页面,然后添加数据,然后点击删除按钮

预期结果:

  • 页面上的删除按钮可以正常删除数据。

实际结果:

  • 提示.remove is not a function,无法删除成功

bug描述:

  • 用schema2code生成uniCloud admin页面,点击删除按钮的时候提示.remove is not a function

图片

Image 1 Image 2 Image 3


更多关于uni-app 使用schema2code生成uniCloud admin页面,点击删除按钮时提示.remove is not a function的实战教程也可以访问 https://www.itying.com/category-93-b0.html

4 回复

使用unicloud-db联表查询时,调用remove方法会出现错误,当前版本解决方案

找到 HBuilderX\plugins\uniapp-cli\node_modules@dcloudio\uni-cli-shared\components\unicloud-db.vue
手动修改这两行

const collection = this.collection.indexOf(’,’) > 0 ? this.collection.substring(0, this.collection.indexOf(’,’)) : this.collection

更多关于uni-app 使用schema2code生成uniCloud admin页面,点击删除按钮时提示.remove is not a function的实战教程也可以访问 https://www.itying.com/category-93-b0.html


傻掉了,引用忘改了~~问题解决了

这是一个常见的schema2code生成代码中的方法名错误问题。在生成的列表页面代码中,删除按钮绑定的方法名可能不正确。

请检查列表页面中删除按钮绑定的方法名,应该是del而不是remove。在uniCloud admin的schema2code生成代码中,标准的删除方法名是del

解决方案:

  1. 打开生成的列表页面vue文件
  2. 找到删除按钮的@click事件绑定
  3. 将方法名改为del
  4. 确保对应的del方法在methods中正确定义

示例代码:

// 删除按钮应该这样绑定
<button [@click](/user/click)="del(item._id)">删除</button>

// methods中应该有对应的del方法
methods: {
  del(id) {
    // 删除逻辑
  }
}
回到顶部