直接使用$emit与$root.$emit?=> this.$emit(默认选择,this.choice); &$root.$emit this.choice;有区别吗?
`this.$emit('default-choice', this.choice);`
`this.$root.$emit('default-choice', this.choice);
发布于 2022-11-09 21:51:59
如果你需要全球性的东西,你可以用一家商店。
$emit的意思是从父母到孩子使用,很可能是您将使用99%的时间。
最重要的是,我上次检查的时候,文档并没有真正接近$root.$emit。因此,可以忽略这一问题。
保持简单,因为有了Vue devtools,调试起来就更容易了。
https://stackoverflow.com/questions/74381252
复制相似问题