组件方法可以不写在methods里吗?

小程序 文章 2020-08-20 17:41 546 0 全屏看文

AI助手支持GPT4.0

组件方法可以不写在methods里吗?Can component methods not be written in methods?

组件方法可以不写在methods里吗?

主页面引用此组件,触发函数,A会执行,B不执行,这样有什么区别

The main page refers to this component and triggers the function. A will execute and B will not. What is the difference

回答:

搞文艺的猿:

methods是自定义组件的方法集合,需要在自定义组件中通过 this.triggerEvent("name",{带参数})这样方式传递到page里面

Trafalgar Lu:我这样写可以吗,我不触发腹肌函数,不带参数,只是实现跳转效果,在A那里实现跳转
仙ღ₅₂₀¹³¹⁴:

A是普通页面写方法的地方。

B的methods是自定义组件内放方法的地方,

你不可以在普通页面里写methods,里面的方法不会执行。

Trafalgar Lu:好的,谢谢了, 可能是我结构有问题,重新生成页面,在methods里写 可以了

-EOF-

AI助手支持GPT4.0