vue(4)v-model input双向绑定

1.将上一届的App.vue文件改为下面的代码:

<template>
    <div>
        {{msg}}
        <input type="text" v-model="msg">//这里写了一个input框, v-model="msg"的意思是将input框中输入的值双向绑定到msg属性上,当我们在页面的input框输入的时候msg会实时改变为输入的值,同样当我们在代码中改变msg的值的时候,input框中的值也会变为msg的值
        
    </div>
</template>

<script>
export default {
   name:"App",
   data:function(){
       return {msg:'this is a test'}
   }
}
</script>

<style scoped>

</style>
原文地址:https://www.cnblogs.com/maycpou/p/14691231.html