英文:
Vue3 - Inherited property from parent
问题
Is there a way that I can propagate a readonly property to all nested components without needing to declare a 'readonly:boolean' property in every component?
英文:
I'm creating some components, is there a way that I can propagate a reaonly property to all nested(with nested components) without needing to declare a 'readonly:boolean' property in every component?
答案1
得分: 1
Use provide('name', var)
in your parent component and const var = inject('name')
in your descendant components: https://vuejs.org/guide/components/provide-inject.html
英文:
Use provide('name', var)
in your parent component and
const var = inject('name')
in your descendant components:
https://vuejs.org/guide/components/provide-inject.html
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论