lundi 24 août 2020

[Vue warn]: Error in mounted hook: "ReferenceError: google is not defined"

I'm trying to implement Google autocomplete using this link:

https://www.npmjs.com/package/vue-google-autocomplete

But I'm getting this error:

VM2823 app.js:62045 [Vue warn]: Error in mounted hook:
"ReferenceError: google is not defined"
     
    found in
     
    ---> <VueGoogleAutocomplete> at node_modules/vue-google-autocomplete/src/VueGoogleAutocomplete.vue
           <user> at resources/js/components/addUser.vue
             <Root>
<template>
    <div>
        <h2>Your Address</h2> 
        <vue-google-autocomplete
            ref="address"
            id="map"
            classname="form-control"
            placeholder="Please type your address"
            v-on:placechanged="getAddressData"
            country="sg"
        >
        </vue-google-autocomplete>
    </div>
</template>
     
<script>
import VueGoogleAutocomplete from 'vue-google-autocomplete'
     
export default {
    components: { VueGoogleAutocomplete },
 
    data: function () {
        return {
            address: ''
        }
    },
     
    mounted() {   
        this.$refs.address.focus();
    },
     
    methods: {       
        getAddressData: function (addressData, placeResultData, id) {
            this.address = addressData;
        }
    }
}
</script> 

Please help to sort out my issue.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire