<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script type="text/javascript" src="js/vue.js"></script>
<title>Document</title>
</head>
<body>
<div id="root">
<h5>插值语法实现姓名输入拼接</h5>
<input type="text" v-model="f">
<input type="text" v-model="l">
全名:<span>{{fl}}</span>
<hr/>
</div>
<script type="text/javascript">
new Vue({
el:'#root',
data:{
f:'尚',
l:'硅谷',
fl:'尚硅谷',
},
watch:{
f(value){
setTimeout(() => {
this.fl=value+'-'+this.l
}, 1000);
},
l(value){
this.fl=this.f+'-'+value
}
}
})
</script>
</body>
</html>
vue样式属性
最新推荐文章于 2024-02-10 11:24:33 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)