Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuxt: Unexpected token <

Nuxt: Unexpected token <

I am working on a nuxt project, and I'm trying to build a map component using google maps and the plugin https://www.npmjs.com/package/vue2-google-maps. I have installed the plugin using npm

In my index.html page I have a normally working page that looks like:

<template>
   <div>

<br>
<br>
       <Card/>
<br>
<br>
<br>
<br>
       <!-- <Googlemap/> -->
       <Panel/>
       <Four/>
       </div> 
</template>

<script>

import Panel from '~/components/panel.vue'
import Card from '~/components/detailCard.vue'
// import GoogleMap from '~/components/googleMap.vue'


export default {

  components: {

    Panel,
    Card,
//     GoogleMap
  }

}
</script>

When I Uncomment the 3 lines with Googlemap in them I get the error in the screenshot .

The Googlemap component is:

<template>
  <GmapMap
  :center="{lat:10, lng:10}"
  :zoom="7"
  map-type-id="terrain"
  style="width: 500px; height: 300px"
>
  <GmapMarker
    :key="index"
    v-for="(m, index) in markers"
    :position="m.position"
    :clickable="true"
    :draggable="true"
    @click="center=m.position"
  />
</GmapMap>

</template>


<script>
import Vue from "vue";
import * as VueGoogleMaps from "vue2-google-maps";

Vue.use(VueGoogleMaps, {
  load: {
    key: "MYTOKEN",
    libraries: "places"
  }
});

export default {

}

</script>


<style>

</style>

What am I doing wrong?

edit:

enter image description here

like image 895
user1592380 Avatar asked Dec 31 '22 22:12

user1592380


1 Answers

Most likely you are missed transpile

https://github.com/xkjyeah/vue-google-maps/blob/0985d475496083f2459db2960ba8f9317aab50ef/README.md#nuxtjs-config

transpile: [/^vue2-google-maps($|\/)/]
like image 166
Aldarund Avatar answered Jan 08 '23 03:01

Aldarund