01 === "parent child transmission using a function of the way to accept
zi.vue
<Template>
<div>
subcomponents:
<span> hHA </ span>
<@ the Click the Button =" clickBtn "> point to my father passed </ button >
</ div>
</ Template>
Export default {
data () { return {
MSG: "father to son data transfer"
}
},
Methods: {
clickBtn () { the this $ EMIT ( "GetVal",. the this a .msg) // trigger custom event parameter 1: name of the custom event parameter 2: parameters to be passed }
},
}
fu.vue
PS =====>
In all event handlers (whether static or dynamic) are not automatically trigger a custom event to manually trigger on a custom assembly, binding
<Template>
<div>
parent component:
<Child @ GetVal = "getzivalue"> < / Child>
</ div>
</ Template>
<Script>
Import from Child "../zi/zi"
Export default {
Components: {
Child
},
Data () {
return {
}
},
Methods: {
getzivalue (Mess) {
the console.log ( "parameters passed over son" + Mess) // outputs "father to son data transfer"
}
}
}
</ Script>
01 ==== "interview questions
1. v-if和v-show的区别?
v-if使用的是节点操作,removeChild或者appendChild
v-show使用的是css的dispaly来进行隐藏和显示
2. props和data的区别?
data是组件内部数据,由组件自己创建,自己维护
props是外部数据,由外部创建传入,由外部维护!