我有一个 npm 包,@Google/maps
我想将它用作我的应用程序的一部分。但不幸的是,该软件包在节点服务器上使用。
但是我有一个没有服务器的 spa Nuxt 应用程序,所以我怎么还能使用它呢?另外,我不想求助于其他 vue npm 包。
这是我到目前为止所拥有的:
~/plugins/server-only.js
import Vue from 'vue'
const GoogleClient = require('@google/maps')
Vue.use(GoogleClient)
~/components/organisms/helloWorld.vue
// ... Vue template
// Vue Js
export default {
mounted() {
console.log(this.$GoogleClient); // undefined
}
}
我想归根结底就是这个。如何导出 Google 地图以便将其导入客户端 vue 组件?
谢谢