Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vue+typescript中引入第三方模块 #9

Open
natee opened this issue Apr 11, 2019 · 0 comments
Open

vue+typescript中引入第三方模块 #9

natee opened this issue Apr 11, 2019 · 0 comments

Comments

@natee
Copy link
Owner

natee commented Apr 11, 2019

IDE:VS Code
Vue + TypeScript

现象:引入vue-lazyload,虽然已经在本地安装,但是typescript还是提示找不到模块。原因是typescript是从node_modules/@types目录下去找模块声明,有些库并没有提供typescript的声明文件,所以就需要自己去添加。

解决方法:
src目录下新建types-shims/tools.d.ts文件,增加如下代码:

declare module 'qs' {
  const qs: any;
  export default qs;
}

declare module 'vue-awesome-swiper' {
  export const swiper: any
  export const swiperSlide: any
}

declare module 'vue-lazyload'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant