组件实例的作用域是孤立的。这意味着不能并且不应该在子组件的模板内直接引用父组件的数据。
可以使用 props 把数据传给子组件。

for-child-msg="aaa" ,
for-child-msg可以当变量名,''aaa''是要传递给子组件的数据
子组件props:[for-child-msg] 接受父组件传递过来的变量名
{{forChildMsg}} 父组件传递过来的数据


html:

| sunny-cheng |
|
||
![]() |
|
|
博客园
|
|