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>
浙公网安备 33010602011771号