首页 > TAG信息列表 > searchInput

vue+ts使用$refs属性报错Property 'focus' does not exist on type 'Vue | Element | (Vue | Elem

问题 项目中直接使用 this.$refs.searchInput.focus() 会报以下错误 Property 'focus' does not exist on type 'Vue | Element | (Vue | Element)[]' 原因 ts中类型不明确引起的 解决 先定义searchInput的类型,再进行后续操作 let SI:any=this.$refs.searchInput SI.focus()

查漏补缺——说说addEventListener和removeEventListener的参数?

问题 如题所示 答案 js添加事件和移除事件:addEventListener()与removeEventListener() 源码如下: watch:{ show(value) { if (value) { document.body.addEventListener('click', this.close) } else {