The console prints the error content as follows:
[渲染层错误] Call method on a non-custom-component node is invalid. Call on the owner component or page instead. To avoid this error hint, try not to call method on `event.instance` , but on `ownerInstance` instead.
After testing, it can be called normally, but it is unbearable to report errors.
Originally, I wanted to obtain a component instance to change its style, and then directly called the `callMethod` method of the component instance, but the console reported an error. The code example is as follows:
module.exports = {
touchstart: function(event, instance) {
var test = instance.selectComponent('.test');
// ...
test.callMethod('testCallMethod', {});
}
}
I have never understood the reason. After looking at the official documentation, I noticed that the documentation stated that it is "current component/instance" to understand what is wrong.
The correct code example is as follows:
module.exports = {
touchstart: function(event, instance) {
// ...
instance.callMethod('testCallMethod', {});
}
}