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

Does vue refer to single data flow or two-way data flow

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article is about whether vue refers to single data flow or two-way data flow. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Vue is a single data stream. Although vue has bi-directional binding "v-model", the data transfer between vue parent and child components still follows an one-way data flow. The parent component can pass props to the child component, but the child component cannot modify the props passed by the parent component, and the child component can only notify the parent component through events to make data changes.

The operating environment of this tutorial: windows7 system, vue2.9.6 version, DELL G3 computer.

Two-way binding

In short, two-way binding is that the update of model will trigger the update of view, the update of view will trigger the update of model, and their functions are mutual.

[failed to upload picture... (image-81a06f-1556975918443)]

Unidirectional data flow

In short, one-way data flow is that the update of model will trigger the update of view, and the update of view will not trigger the update of model. Their function is unidirectional.

Isn't that nonsense? everyone knows that.

Here is the real practical information. Sit down on the bench.

Vue is an one-way data flow, not a two-way binding of Vue, but a grammatical sugar. Object.definePropert is the implementation principle of v-model, which is used for responsive updates.

Put it on the component

Parent component

Put it on the input element

In fact, the above has already reflected

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