:onChange和@change有什么区别吗?Is there any diffrence between :onChange and @change? #11348
-
我试了下对一个组件传入:onChange也能触发组件的事件,表面效果好像和@change一样,但是官网没有说明。 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
As stated in the docs, That being said, |
Beta Was this translation helpful? Give feedback.
-
没有区别。 请看 playground。 你可以通过右边的“JS”标签页查看模板编译后的结果,在21行和22行会发现, 你也可以在官方文档的 渲染函数 发现,如果你使用 |
Beta Was this translation helpful? Give feedback.
没有区别。
请看 playground。 你可以通过右边的“JS”标签页查看模板编译后的结果,在21行和22行会发现,
@change
在编译后会变成onChange
,作为createElementVNode的第二个参数传递。你也可以在官方文档的 渲染函数 发现,如果你使用
h()
或者jsx
,那么应该使用on开头的小驼峰命名法作为prop
来注册一个监听事件,比如onChange
=@change
。