基于vue脚手架的练习2
<template> <div> <span>父值为:</span>{{ to_value }} <button @click="clear()">清空</button> </div> </template> <script> export default { props:['to_value'], methods:{ clear(){ this.$emit('re_value','') } } } </script> <style> </style>
<template> <div class="project"> <input type="text">{{ value }} <first-page-2 :to_value="value" v-model="value" @re_value="value=''"></first-page-2> </div> </template> <script> import FirstPage2 from './FirstPage2.vue' export default { components: { FirstPage2 }, data(){ return { value:'123' } }, methods:{ } } </script> <style scoped> .project{ background-color: #46ac31; margin: 5px; padding: 20px; } </style>
父子通信,