代码如下
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div id="app">
lazy,默认情况是实时更新数据,加上lazy,从输入框失去焦点,按下enter都会更新数据<br>
<input type="text" v-model.lazy="msg">
<h2>{{msg}}</h2>
修饰符number,默认是string类型,使用number赋值为number类型<br>
<input type="number" v-model.number="age">
<h2>{{age}}--{{typeof age}}</h2>
修饰符trim:去空格<br>
<input type="text" v-model.trim="name">
</div>
<script src="../vue.js"></script>
<script>
const app=new Vue({
el:"#app",
data(){
return{
msg:'张三',
age:28,
name:"李四"
}
}
})
</script>
</body>
</html>