vue watch监听触发节流
作者:互联网
export default { name: 'HelloWorld', props: { msg: String }, data () { return { search: { input: '', timer:null } } }, watch: { 'search.input': { handler (value) { if (this.timer) { clearTimeout(this.timer) } this.timer = setTimeout(() => { this.getList(); }, 1000) }, deep: true } }, methods: { getList(){ //在这里你可以请求你的接口,拿到你想要的数据 console.log(1) } } } </script>
标签:search,vue,节流,getList,watch,timer,input,methods 来源: https://www.cnblogs.com/Allen-project/p/14193632.html