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()

相关文章

可以通过min-width属性来设置el-table-column的最小宽度。以...
yarn dev,当文件变动后,会自动重启。 yanr start不会自动重...
ref 用于创建一个对值的响应式引用。这个值可以是原始值(如...
通过修改 getWK005 函数来实现这一点。这里的 query 参数就是...
<el-form-item label="入库类型" ...
API 变动 样式类名变化: 一些组件的样式类名有所变动,可能需...