vue父组件给子组件传值小结

    xiaoxiao2022-07-05  188

    问题描述:父组件为parent.vue 子组件为child.vue 且二者在同级目录下,现在parent.vue里边有个值parentToChildValue,想将其传到子组件child.vue中 parent.vue的格式为:

    <template> <div> <child :parentToChildValue="parentToChildValue"> </child> </div> </template> <script> import jquery from "../../js/jquery-1.12.4.min" import child from "./child" export default { data () { return { parentToChildValue:'', } }, components:{ child }, computed:{ }, methods:{ }, mouted(){ } </script> <style> </style>

    child.vue的格式为:

    <template> <div> </div> </template> <script> import jquery from "../../js/jquery-1.12.4.min" export default { name:'child', data () { return { } }, props:['parentToChildValue'], methods:{ }, mouted(){ } </script> <style> </style>

     

    最新回复(0)