首页 > 其他 > 详细

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

时间:2021-04-23 00:49:30      阅读:14      评论:0      收藏:0      [点我收藏+]

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>

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

原文:https://www.cnblogs.com/maycpou/p/14691231.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!