Open darior87 opened 6 years ago
Hello darior87,
I ran into the issue you had. The problem is that the google script isn't loaded. I found a way to make it work, but I'm not sure if it's a good practice.
My plugin file contains the content as you:
import Vue from 'vue';
import VueGoogleAutocomplete from 'vue-google-autocomplete';
Vue.use( VueGoogleAutocomplete );
Vue.component('vue-google-autocomplete', VueGoogleAutocomplete);
But in the nuxt.config file, I added a line in head
:
script: [{ src: "https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY_HERE&libraries=places "}],
Any update in this issue. I'm still facing the same issue
I had the same issue, I solve using this trick
In template
<no-ssr>
<vue-google-autocomplete
id="address"
classname="class"
placeholder="Start typing"
v-on:placechanged="getAddressData">
</vue-google-autocomplete>
</no-ssr>
In Script
components: {
VueGoogleAutocomplete: () => import('vue-google-autocomplete')
},
methods: {
getAddressData(addressData, placeResultData, id) {
}
}
Don't forget to add script in nuxt.config file
That's it, Good luck :)
Same, but without no-ssr tag:
nuxt.config:
plugins: [ { src: '~plugins/vue-google-autocomplete', ssr: false } ],
SO
I'm having problems when loading the page containing vue-google-autocomplete module. the problem is shown below
The version is
1.1.0
(the latest) and the nuxt version is2.1.0
while the node version is10.4.1
I'm facing the exact problem even when starting the
nuxt generate
command.Tried also loading globally with placing the load of this module inside the plugins using
Vue.component('vue-google-autocomplete', VueGoogleAutocomplete);
without any luck.Any suggestions?