-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
组件上传递的事件会自动绑定到组件内部所有元素上 #457
Conversation
DOM 里面事件是会冒泡的... 你点击子元素当然会出发父元素的 click 事件了 |
可是我并没有在父元素上绑定事件啊,组件外部传递的事件不应该主动绑定到根元素上吧 |
而且测试用例和实际使用情况展现的完全两种情况 这也是不应该的啊 |
@yyx990803 这好像说的是没有 |
@Justineo @yyx990803 对就是想说这个。 2.0的时候只有在.native的时候才会添加到根元素上 |
新的attr fallthrough rfc里移除了.native vuejs/rfcs#92 |
@fnlctrl 谢谢 这么说以后都得加上 inheritAttrs: false, |
要等这个rfc最终敲定了才能确定,也有可能有变动。目前的实现是这个行为。 |
这是因为 runtime-test 没有实现冒泡。放到 runtime-dom 里的测试应该就一致了。 |
简单来说,以后默认所有没有被声明为 props 的属性(包括 class, style, 事件和普通的 attribute)都会被子组件的根元素继承。如果想要订制这个行为,就用 |
应该是 |
组件内部并没有主动触发外部绑定的事件,但是事件会自动绑定到所有子元素上。
packages/vue/examples/todomvc-composition.html
packages/runtime-core/tests/apiSetupContext.spec.ts
很奇怪 , 测试用例里是没有问题的。但是在实际使用过程中会出现。