1

I'm trying to build this simple app, but I always get this error

Uncaught ReferenceError: Vue is not defined.

<template>
  <v-app>

  <div id="example-1">
  <v-btn v-on:click="counter += 1">Add 1</v-btn>
  <p>The button above has been clicked {{ counter }} times.</p>
</div>

  </v-app>
</template>

<script>

var example1 = new Vue({
  el: '#example-1',
  data: {
    counter: 0
  }

})

</script>
5
  • Have you imported vue anywhere? Commented Oct 4, 2019 at 10:05
  • Did you add the cdn for vuejs? Commented Oct 4, 2019 at 10:08
  • The error says to you what is wrong. You didn't define Vue anywhere. Commented Oct 4, 2019 at 10:11
  • @evolutionxbox yes, i imported vue in the main.js file : import Vue from 'vue' Commented Oct 4, 2019 at 10:24
  • 2
    You're missing the important part - how and where you are importing Vue, this isn't a viable question unless you provide that Commented Oct 4, 2019 at 10:37

2 Answers 2

2

Replace template tag with the div and add cdn at least before </body> tag:

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>

<div>
  <v-app>
    <div id="example-1">
      <button v-on:click="counter += 1">Add 1</button>
       <p>The button above has been clicked {{ counter }} times.</p>
    </div>
  </v-app>
</div>

<script>

var example = new Vue({
    el: '#example-1',
    data: {
      counter: 0
    }
  })

</script>

I replaced v-btn with the button just to show that it works.

Sign up to request clarification or add additional context in comments.

Comments

0

This syntax with "template" and "v-btn" means that you want to use a vue file. If it's the case, you have to use something to interpret those files(vue-cli).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.