当前位置:网站首页>监视文本框的输入
监视文本框的输入
2022-08-09 07:57:00 【scwMason】
watch属性
<div id="app">
<input type="text" v-model="fir">+
<input type="text" v-model="sec">=
<input type="text" v-model="full">
</div>
<script>
var vm=new Vue({
el:"#app",
data:{
fir:'',
sec:'',
full:''
},
methods:{},
watch:{
fir:function(){//fir可以加引号也可不加,如果是fir-name这样的形式就要引号
this.full=this.fir+this.sec
},
sec:function(){
this.full=this.fir+this.sec
}
}
})
</script>
watch里面就实现了对两个文本框的监视
keyup事件监听
监听路由变化
watch:{
'$route.path':function(newval,oldval){
console.log(newval+'---'+oldval)
}
}
computed计算属性值
computed:{
'full':function(){
return this.fir+this.sec
}
}
这样就不用在data中设置我们的属性,可以直接用“full”这个属性:
<input type="text" v-model="full">
并且我们这个属性值当第一次被用到的时候就会被调用并且缓存起来,所以computed里面的函数只调用一次
边栏推荐
猜你喜欢
Four departments including the Ministry of Industry and Information Technology promote green smart home products to the countryside
传输层协议介绍
SOLIDWORKS 2022新功能直播揭秘!速来围观!
String类创建的对象在JVM中的内存分配和equals与==的区别
SSM integration development case
Selenium测试案例一步步学之(2)Selenium自动测试脚本模块化(下)
SOLIDWORKS Simulation教程:计算物体的固有频率
3安装及管理程序
pytorch指定GPU
MDK Keil debug时, watch1中全局变量不更新
随机推荐
VOC格式标签转YOLO格式
SA-Siam:用于实时目标跟踪的双重连体网络A Twofold Siamese Network for Real-Time Object Tracking
EXCEL使用函数联调(find,mid,vlookup,xlookup)
Redis(八)集群
C language: detailed explanation of soda bottle
.net(三) 项目结构
C#高级学习1
js数组相关知识复习
权限(下)
权限(上)
LeetCode·每日一题·636.函数的独占时间·栈模拟
Solidworks 2022 Inspection新增功能:光学字符识别、可自定义的检查报告
(error) NOAUTH Authentication required.
配置本地yum源仓库
传输层协议介绍
Exclude null values when Oracle limits
Anaconda use proxy
H3C_利用策略路由实现出口双线路负载(选路)的部署
Four departments including the Ministry of Industry and Information Technology promote green smart home products to the countryside
研发分享:机器学习卡片的使用