vue使用节流函数
<html>
<head>
<script type="text/javascript" src="https://unpkg.com/vue@3.2.19/dist/vue.global.js"></script>
<script type="text/javascript" src="https://cdn.staticfile.org/lodash.js/4.17.21/lodash.min.js"></script>
</head>
<body>
<div id="app">
<input type="text" v-model="name"/>
</div>
<div id="app_immediate">
<input type="text" v-model="name"/>
</div>
</body>
<script type="text/javascript">
Vue.createApp({
data(){
return {
name:"li"
}
},
methods:{
},
watch:{
name:_.debounce(function(newValue,oldValue){
console.log(newValue,oldValue);
},500)
}
}).mount('#app');
Vue.createApp({
data(){
return {
name:"li"
}
},
methods:{
},
watch:{
name:{
handler:_.debounce(function(newValue,oldValue){
console.log(newValue,oldValue);
},500),
deep:true,
immediate:true
}
}
}).mount('#app_immediate');
</script>
</html>
上一篇:
js内存泄露简单处理方式
下一篇:
ios app打包分发
静水缘首页
文章分类
最新文章
- nodejs私钥加密公钥解密的一个例子
- uniapp和微信小程序判断程序运行在开发或者测试或者线上版本的方法分别是什么
- electron使用electron-builder打包后模块包含exe文件执行失败
- Compile is disallowed on the main thread, if the buffer size is larger than 4KB
- better-sqlite3简介及常用操作
- nodejs 操作数据库的库
- nodejs使用http-proxy库实现多个域名代理和同时代理websocket的例子,代理包含https和http两种协议
- iis配置反向代理
- javascript伪多线程代码
- ip所在地址段判断