swan.setEnableDebug

基础库 1.12 开始支持,在工具和真机中的实现有区别,详见 API 实现差异

解释:设置是否打开调试开关,此开关对正式版也能生效。

Web 态说明:Web 态小程序暂不支持设置调试模式。

方法参数

Object object

object 参数说明

属性名类型必填默认值说明Web 态说明

enableDebug

Boolean

是否打开调试

success

function

接口调用成功的回调函数,仅支持 Android

暂不支持

fail

function

接口调用失败的回调函数,仅支持 Android

支持 iOS、Android

complete

function

接口调用结束的回调函数(调用成功、失败都会执行),仅支持 Android

支持 iOS、Android

示例

跳转编辑工具

在开发者工具中打开

在 WEB IDE 中打开

扫码体验

代码示例

百度智能小程序

请使用百度APP扫码

图片示例

swan.setEnableDebug - 图2

代码示例

  • SWAN
  • JS
  1. <view class="wrap">
  2. <view class="card-area">
  3. <view class="top-description border-bottom">openEnableDebug</view>
  4. <button type="primary" bindtap="openEnableDebug">button</button>
  5. </view>
  6. <view class="card-area">
  7. <view class="top-description border-bottom">closeEnableDebug</view>
  8. <button type="primary" bindtap="closeEnableDebug">button</button>
  9. </view>
  10. </view>

Bug & Tip

  • 可以先在开发版或体验版打开调试模式,再切回到正式版就能看到调试器。
  • 请确认已登录百度帐号,当前登录用户属于该小程序开发者时,才能打开调试。