![1e6fc77a0a4aa6d769ac12307e0e736c.png](https://i-blog.csdnimg.cn/blog_migrate/21356b60c9d4bef0244d3a84f95802e3.png)
1.Property ‘validate’ does not exist on type ‘Vue | Element | Vue[] | Element[]’.Property ‘validate’ does not exist on type ‘Vue’.Vetur(2339)
![6376d1e58139d8ae9d6f0df1d65a4690.png](https://i-blog.csdnimg.cn/blog_migrate/5a33bdbbd63edf6fc589b46fcbb12319.jpeg)
方法一:
(this.$refs.dataForm as any).validate() //这样就不报错了
![83bdf70ff8a7e1435d096cdb171b7ba4.png](https://i-blog.csdnimg.cn/blog_migrate/f2bd6271da6ba0dcd0194a0d876cd478.png)
方法二:
先在js里头的前面引入element 的Form,再as Form
import {Form} from "element-ui";
(this.$refs.dataForm as Form).validate();
![715d21c91efa70374a6690a7459d20e5.png](https://i-blog.csdnimg.cn/blog_migrate/7775c45fcebdc52e50e7f2e36f2cd693.png)
![e132028f0d35126e51d307347628da46.png](https://i-blog.csdnimg.cn/blog_migrate/0e6546b803177e734753c2b9a6e83627.png)
参考:https://blog.csdn.net/qq_35257117/article/details/91362483
http://2.xxx does not exist on type ‘AxiosResponse’.Vetur(2339)
![a13a75e3a542751b2f2fcc638b1b2c8c.png](https://i-blog.csdnimg.cn/blog_migrate/a2df666100b5887ddb687ac76a003d8e.png)
解决方案:
1.新建axios.d.ts文件,如在该目录: src/types/axios/axios.d.ts
2.axios.d.ts文件内容
import * as axios from 'axios'
declare module 'axios' {
interface AxiosInstance {
(config: AxiosRequestConfig): Promise<any>
}
}
3.修改项目第一层目录下的tsconfig.json配置文件
{
"compilerOptions": {
"typeRoots":[
"./node_modules/@types",
"./src/types/"
]
}
}
4.关闭前端服务器,再重启vscode,试试效果,不报错了
![bf56c533438d93d850a920341adcea49.png](https://i-blog.csdnimg.cn/blog_migrate/1ddaaceffcdef5f76d5b09509b1fd4fd.jpeg)
参考:https://github.com/axios/axios/issues/1510#issuecomment-529284409