基于vue脚手架的练习2

发布时间 2023-12-08 14:46:33作者: 子过杨梅
<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>

父子通信,