We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
parent.vue
<childrenComponent :data='price'></childrenComponent> export default { data() { return { price: 10 } } }
children.vue
<p>{{price}}</p> export default { props: { price: { type: Number, default: 0 } } }
或者
<p>{{price}}</p> export default { props: ['price'] }
有些时候我们需要再父组件直接执行子组件的方法:
<childrenComponent></childrenComponent> export default { mounted() { this.$refs.children.handleClick(); } }
export default { methods: { handleClick() { alert("父组件在执行我"); } } }
<childrenComponent @childrenClick="parentClick"></childrenComponent> export default { methods: { parentClick() { alert("子组件派发给我的"); } } }
export default { methods: { handleClick() { this.$emit('childrenClick', ''); } } }
1:使用一个中间件来传递数据信息
2:使用vuex
The text was updated successfully, but these errors were encountered:
No branches or pull requests
父组件->子组件
parent.vue
children.vue
或者
有些时候我们需要再父组件直接执行子组件的方法:
parent.vue
children.vue
子组件->父组件
parent.vue
children.vue
任意组件之间通信
1:使用一个中间件来传递数据信息
2:使用vuex
The text was updated successfully, but these errors were encountered: