props双向绑定?v-bind.sync=''


<template>
    <div>
      <children v-bind:title.sync="title"/>
    </div>
</template>
<script>
export default {
  data(){
    return{
       title:"学习vue"
    }
  }
}
</script>

 

子组件:

<template>  
<div> <span>标题:{{title}}</span> <el-button @click="update">点击修改</el-button> </div> </template> <script> export default { name:"children", data(){ return{} }, props:{ title:String }, methods:{ update(){ this.$emit("update:title",'修改成功') } } } </script> <style>
</style>

 

posted on 2022-06-15 14:55  久居我梦  阅读(73)  评论(0编辑  收藏  举报

导航