鍍金池/ 問答/HTML5  HTML/ 調(diào)用的時候提示callback.call is not a function,新

調(diào)用的時候提示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)
      }
    })
  }
回答
編輯回答
久愛她

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

2018年2月16日 15:37
編輯回答
孤巷

請確定你傳入的callback是function類型

2018年8月4日 22:11