Callback must be a function. Received { recursive: true }
时间: 2024-05-19 08:16:05 浏览: 16
This error message is usually encountered when a non-function value is passed as a callback parameter to a function that expects a function as the callback.
For example, in Node.js, the `fs.readdir()` function expects a callback function as its second parameter. If a non-function value is passed instead, such as an object with a `recursive` property set to `true`, the error message "Callback must be a function. Received { recursive: true }" will be thrown.
To fix this error, make sure that you are passing a function as the callback parameter when necessary. Check the documentation of the function you are working with to see what type of parameter is expected as the callback.
相关问题
Error in callback for watcher "uList.innerScrollTop": "TypeError: this.parent.updateOffsetFromChild is not a function" found in
CSDN开发的ChatGPT的回答:
对于这个错误信息,它表明在"uList.innerScrollTop"的watcher回调中存在一个错误。具体错误是"TypeError: this.parent.updateOffsetFromChild is not a function"。这个错误通常发生在尝试调用一个未定义的函数时。根据提供的信息,我无法确定具体的原因,因为我没有上下文信息。但是,可能的原因之一是在调用父组件的updateOffsetFromChild函数时出现了问题。建议检查代码中是否正确引用了父组件,并确保该函数存在且可用。如果仍然无法解决问题,建议检查相关文档或寻求更多帮助以获取更详细的上下文信息。
class AbstractListener(threading.Thread): """A class implementing the basic behaviour for event listeners. Instances of this class can be used as context managers. This is equivalent to the following code:: listener.start() listener.wait() try: with_statements() finally: listener.stop() Actual implementations of this class must set the attribute ``_log``, which must be an instance of :class:`logging.Logger`. :param bool suppress: Whether to suppress events. Setting this to ``True`` will prevent the input events from being passed to the rest of the system. :param kwargs: A mapping from callback attribute to callback handler. All handlers will be wrapped in a function reading the return value of the callback, and if it ``is False``, raising :class:`StopException`. Any callback that is falsy will be ignored. """解释一下
这是一个抽象类 `AbstractListener`,继承自 `threading.Thread`。它实现了事件监听器的基本行为,可以用作上下文管理器。
使用该类的实例作为上下文管理器,等价于以下代码:
```
listener.start()
listener.wait()
try:
with_statements()
finally:
listener.stop()
```
该类的实际实现需要设置一个名为 `_log` 的属性,该属性必须是 `logging.Logger` 类的实例。
该类的构造函数有一个布尔型参数 `suppress`,用于控制是否禁止事件传递给系统的其他部分。如果将其设置为 `True`,则事件将被禁止传递。
另外,构造函数还可以接收一个关键字参数 `kwargs`,该参数是一个从回调属性到回调处理程序的映射。所有的处理程序都将被封装在一个函数中,该函数会读取回调的返回值,如果返回值为 `False`,则引发 `StopException`。任何回调都不为真时将被忽略。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)