typescript使用钉钉api的问题

禁用下拉刷新和弹性功能的时候disable()有红色波浪线,这种调用方法该怎么写参数呢?

dd.ready(() => {
    dd.ui.pullToRefresh.disable()
    dd.ui.webViewBounce.disable()
})

// 错误提示如下:
// (property) disable: (params: IUiPullToRefreshDisableParams) => Promise<IUiPullToRefreshDisableResult>
// Expected 1 arguments, but got 0.Vetur(2554)

还有这种使用的api里面有success方法也会提示报错,意思是没有这个方法?请求大佬们解答一下

dd.device.geolocation.get({
    targetAccuracy: 200,
    coordinate: 1,
    withReGeocode: false,
    useCache: true,
    onSuccess: (success: any) => {
      resolve(success)
    },
    onFail: (fail: any) => {
      alert('获取地理位置失败:' + JSON.stringify(fail))
    }
})

// 错误信息如下:
// Argument of type '{ targetAccuracy: number; coordinate: number; withReGeocode: false; useCache: true; onSuccess: (success: any) => void; onFail: (fail: any) => void; }' is not assignable to parameter of type 'IDeviceGeolocationGetParams'.
// Object literal may only specify known properties, and 'onSuccess' does not exist in type 'IDeviceGeolocationGetParams'.Vetur(2345)
阅读 5.6k
1 个回答

我在shims-vue.d.ts文件(引入第三方库的时候都需要在这个文件中声明一下),所以我在我这里加一行这个declare module 'dingtalk-jsapi'就可以了。只是现在vscode会有红色波浪线,但是运行和打包已经没有问题了,可能是哪个tslint的配置问题吧。

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