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

2022/6/15 23:24:26

本文主要是介绍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>

 



这篇关于props双向绑定?v-bind.sync=''的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程