例如以下代码,函数需要节流/防抖,在方法外面套了一层throttle(),
someTap: throttle(async function () {
const formGroup = this.data.formGroup;
const isSingle = this.data.isSingle;
//...
}),
但是方法里面要用到this,使用TS的项目里,工具会提示错误:
此容器隐藏了 "this" 的外部值
但是没有给解决方法
扫描小程序码分享
例如以下代码,函数需要节流/防抖,在方法外面套了一层throttle(),
someTap: throttle(async function () {
const formGroup = this.data.formGroup;
const isSingle = this.data.isSingle;
//...
}),
但是方法里面要用到this,使用TS的项目里,工具会提示错误:
此容器隐藏了 "this" 的外部值
但是没有给解决方法
ts 中需要把this 作为一个参数传递进来。