调用的时候提示callback.call is not a function,新手求解

findFolders (data, callback) {
    let postData = ''
    if (data.hasOwnProperty('id')) {
      postData ? postData = postData + '&id=' + data.id : postData = postData + 'id=' + data.id
    }
    if (data.hasOwnProperty('cache')) {
      postData ? postData = postData + '&cache=' + data.cache : postData = postData + 'cache=' + data.cache
    }
    if (data.hasOwnProperty('global')) {
      postData ? postData = postData + '&global=' + 'true' : postData = postData + 'cache=' + data.cache
    }
    ajax.get({
      url: '/folder/findFolders?' + postData,
      success (d) {
        callback && callback.call(this, d)
      }
    })
  }
阅读 8.1k
2 个回答

请确定你传入的callback是function类型

if (typeof callback === "function") callback.call(this, d)

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题