亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - problem of using prop to pass data in vue
歐陽克
歐陽克 2017-06-26 10:56:18
0
3
897

In the vue2.0 document, there is some confusion about the introduction of prop. Since the data of the parent component is obtained through prop, why is it reassigned in the child component after use? Didn't you get the value of the parent component?

Why do we need to attach a message with similar attributes to the child component and assign a value? Shouldn't it be that after writing <child></child> directly, the <span>parent component message value</span> will be automatically displayed? Shouldn't it be displayed like this?

How should I understand this? Why is this so? How should prop be used?

歐陽克
歐陽克

溫故而知新,可以為師矣。 博客:www.ouyangke.com

reply all(3)
扔個三星炸死你

That’s understandable.

The parent component passes values ??to the child component.
<child message='hello'></child>
There are two places where message is used in the sub-component. The props block is a variable that may be used to register.
For example: <child message='hello' dep='ssd'></child>
The corresponding props should be ['message','dep']
template in {{message }} is the real calling variable.
As you said<child></child> Display it directly, it should be like thistemplate: '<span>hello</span> :)

Why is it written in this structure? Taking into account the reusability of components, different functions can be implemented by simply changing the passed in values.

給我你的懷抱

Use v-bind:props='data' in the parent component scope to pass the parent component data to the child component

黃舟

Can it be understood that the child component can also modify the value passed by the parent component?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template