vue: passing props down to all descendants

后端 未结 6 1101
夕颜
夕颜 2021-01-22 18:36

I have a parent component with the following line


6条回答
  •  面向向阳花
    2021-01-22 19:09

    Vue $attrs is the new way to propagate props

    From the Docs:

    vm.$attrs

    Contains parent-scope attribute bindings (except for class and style) that are not recognized (and extracted) as props. When a component doesn’t have any declared props, this essentially contains all parent-scope bindings (except for class and style), and can be passed down to an inner component via v-bind="$attrs" - useful when creating higher-order components.

    For more information, see Vue.js API Reference - $attrs

提交回复
热议问题