Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the value passed by vue father and son, brother and son

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to understand vue father-son value, brother value, son father value", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "how to understand vue father and son value, brother value, son father value" bar!

The parent component passes a value of 1 to the child component. Export default {data () {return {value: 'hello worldview'}} in parent component .vue / / parent component 2. Child component .vue / / parent component {{title}} export default {props: {title: {type: String, default:''}

/ / title value is' hello world!

Second, the values between sibling components can also be transferred through the middleware Bus.

$emit pass value

$on receive

$off delete transfer event

1.A component .jsthis. $bus.$emit ("flag", true) 2.B component .jsmounted () {this.$bus.$off ('flag') this.$bus.$on (' flag', data= > {this.flag= data})} 3. The child component passes the value 1 to the parent component. Parent component .js import Child from'. / components/Child'export default {components: {Child}, data () {return {}}, method: {getTitle (data) {console.log (data)}

The print result is hello xuliting

two。 Child component .js {{title}} export default {data () {return {title: 'hello xuliting'}}, mounted () {this.getFun ()}, method: {getFun () {this.$emit ("getTiltle", this.title)}, I believe you have a deeper understanding of "how to understand vue father-son value, brother value, child father value". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report