Vue.js Nuxt外部源
我是nuxt新手,正在尝试使用外部源(本例中为谷歌api)。在引用之后:我看到脚本被添加到了我的index.html的头部。但是我如何使用它呢 目前我在挂载事件中有以下内容:Vue.js Nuxt外部源,vue.js,nuxt.js,Vue.js,Nuxt.js,我是nuxt新手,正在尝试使用外部源(本例中为谷歌api)。在引用之后:我看到脚本被添加到了我的index.html的头部。但是我如何使用它呢 目前我在挂载事件中有以下内容: mounted: function () { const element = document.getElementById(this.mapName) const options = { zoom: 14, center: new google.maps.LatL
mounted: function () {
const element = document.getElementById(this.mapName)
const options = {
zoom: 14,
center: new google.maps.LatLng(51.501527, -0.1921837)
}
const map = new google.maps.Map(element, options)
}
但我得到了一个错误:
'google' is not defined
谢谢 明白了,你可以通过:window.google输入。明白了,你可以通过:window.google输入