我有以下源代码,当我尝试使用以下命令实例化一个新 var 时,我也遇到了以下错误google.maps ...:
谷歌'未定义
许多答案都谈到在其他所有事情之前异步加载 API 脚本,并且脚本的顺序很重要,但我认为这不是我的问题。
PS:我用这个 main.js
Vue.use(VueGoogleMaps, {
load: {
key: 'MY-KEY',
libraries: 'places', //// If you need to use place input
},
})
Run Code Online (Sandbox Code Playgroud)
谁能帮我?谢谢。
<div class="map-container">
<gmap-map
id="map"
ref="map"
:center="center"
:zoom="15"
map-type-id="roadmap"
style="width:100%; height: 400px;">
<gmap-marker
:key="index"
v-for="(m, index) in markers"
:position="m.position"
@click="center=m.position"
></gmap-marker>
</gmap-map>
</div>
Run Code Online (Sandbox Code Playgroud)
<script>
import _ from 'lodash'
import { mapState } from 'vuex'
import * as VueGoogleMaps from 'vue2-google-maps'
export default {
computed: {
...mapState([
'map',
]),
mapStyle: function …Run Code Online (Sandbox Code Playgroud)