后浪云百度小程序教程:swan.deleteBookshelf

  • swan.deleteBookshelf
    • 方法参数
      • object 参数说明
      • success 返回参数说明
      • list 参数说明
      • 代码示例

    swan.deleteBookshelf

    基础库 3.210.8 开始支持,低版本需做兼容处理。

    解释:删除书架中的内容(需宿主支持书架入口)。
    Web 态说明:Web 态不支持删除书架中的内容,调用会执行失败回调。

    方法参数

    Object object

    object 参数说明

    参数名 类型 是否必填 默认值 说明
    category String - 要删除的内容分类:article(专栏模板)、doc(文档模板)、cartoon(动漫模板)、av(影音模板)。详细模板说明请参见书架同步功能介绍
    contentIds Array.<string> - 要删除书架内容的 id,支持传多个,最多 100 条;注释:contentId 为内容 id,内容的唯一标识,自定义,最长 22 字符(不能含有空格、中文字符)。支持批量删除的同一个 category 下的多个 id,不同 category 下的 id 请分别调用该接口删除
    success Function - 接口调用成功的回调函数
    fail Function - 接口调用失败的回调函数
    complete Function - 接口调用结束的回调函数(调用成功、失败都会执行)

    success 返回参数说明

    参数名 类型 说明
    list Array.<object> 删除书架内容的结果列表

    list 参数说明

    参数 类型 说明
    contentId String 内容的唯一标识
    status Number 删除状态:值为 0 时是失败,为 1 时是成功
    msg String 删除信息

    代码示例

    • JS
     
     
     
    1. swan.deleteBookshelf({
    2. category: 'doc',
    3. contentIds: ['test1', 'test2'],
    4. success(res) {
    5. swan.showModal({
    6. title: 'success',
    7. content: JSON.stringify(res)
    8. });
    9. },
    10. fail(err) {
    11. swan.showModal({
    12. title: 'fail',
    13. content: JSON.stringify(err)
    14. });
    15. }
    16. })
    THE END