简体   繁体   English

无法将 vue2-google-maps 组件导入 main.js

[英]Can't import vue2-google-maps component to main.js

After installing vue2-google-maps with npm, I'm trying to import the component to my main.js.在使用 npm 安装 vue2-google-maps 后,我正在尝试将组件导入我的 main.js。 But I keep getting an error.但我不断收到错误消息。 I never had problem importing packages to main.js or to other.vue files.我从来没有遇到过将包导入 main.js 或 other.vue 文件的问题。

Versions: vue 2.6.10 vue2-google-maps@0.10.7 vue-cli 2.9.6 but also tried with 3.11.0版本: vue 2.6.10 vue2-google-maps@0.10.7 vue-cli 2.9.6 但也尝试使用 3.11.0

import App from "./App.vue";
import store from "./store/store.js";
import * as VueGoogleMaps from "vue2-google-maps";

Vue.use(
  VueGoogleMaps,
  {
    load: {
      key: "AIzaSyBYULuuIqKYMJVrEk1PjpUDQQYkGMmP0iM",
      libraries: 'places'
    }
  }
);


I'm getting the error in this line: import * as VueGoogleMaps from "vue2-google-maps";我在这一行中遇到错误: import * as VueGoogleMaps from "vue2-google-maps";

Error Message: Could not find a declaration file for module 'vue2-google-maps'.错误消息:找不到模块“vue2-google-maps”的声明文件。 'c:/Users/BotiVegh/vueJS_projects/vue-store-gallery-map/node_modules/vue2-google-maps/dist/main.js' implicitly has an 'any' type. 'c:/Users/BotiVegh/vueJS_projects/vue-store-gallery-map/node_modules/vue2-google-maps/dist/main.js' 隐含了一个 'any' 类型。 Try npm install @types/vue2-google-maps if it exists or add a new declaration (.d.ts) file containing declare module 'vue2-google-maps';如果存在,请尝试npm install @types/vue2-google-maps或添加包含declare module 'vue2-google-maps'; ts(7016) ts(7016)

Do I need to change something in the config file?我需要更改配置文件中的某些内容吗?

You could try adding "noImplicitAny": false to your tsconfig.json file您可以尝试在tsconfig.json文件中添加"noImplicitAny": false

This disables warnings on expressions and declarations with an implied 'any' type这将禁用对具有隐含“任何”类型的表达式和声明的警告

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel + Vue JS和Vue2-Google-Maps - Laravel + vue js and vue2-google-maps 如何在vue2-google-maps中填充标记 - How to populate markers in vue2-google-maps Vue.js 无法将数据从 main.js 传递到 App.vue? - Can't pass data from main.js to App.vue in Vue js? 如何在vue.js项目的main.js文件中导入js类并在所有组件中使用它,而不是在每个组件中导入? - How to import a js class in main.js file of a vue.js project and use it in all the components instead of importing in each component? 如何在Vue中将Axios导入main.js? - How do I import Axios into main.js in Vue? 如何从 vue 中的 main.js 文件重新渲染组件? - How to re render component from main.js file in vue? 谷歌地图未使用库 vue2-google-maps 呈现 - Google map not render with library vue2-google-maps Vue - vue2-google-maps 使用道具动态加载 api 密钥? - Vue - vue2-google-maps load api key dynamically with props? 无法将 Firebase 实时数据库中的数据保存到 Vue.js 中的数组,并将其用于在 Vue2-google-maps 上显示标记 - Cannot save data from Firebase realtime database to array in Vue.js, and use it for displaying markers on Vue2-google-maps Vue 3 - 在 main.js 上导入与 vue.config.js 上的附加数据,加载全局 scss 文件 - Vue 3 - import on main.js vs additionalData on vue.config.js, load a global scss file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM