How can I access child component data from a parent in Vue?

前端 未结 1 1192
暗喜
暗喜 2021-01-14 00:51

I am trying to access data from a single-file component in Vue, but can\'t find any way of doing it. I have tried using $emit, but can\'t get thath to work eith

相关标签:
1条回答
  • 2021-01-14 01:32

    You can use the special attribute ref:

    <child-comp ref="child"></child-comp>
    

    In JS:

    vm.$refs.child.YOUR_DATA
    

    Hope this helps!

    0 讨论(0)
提交回复
热议问题