How to attach an external js-vue file with an html file

59 Views Asked by At

i am trying to attach an external js file with my html code to run vue code but i'm getting errors like element not found and vue not declared .

i have tried jsfiddle but it doesn't solve my problem

});As you can see this is a basic code

1

There are 1 best solutions below

0
Michael On

Your main.js needs to look something like this:

import Vue from 'vue'
import App from './App'
new Vue({
  el: '#app',
  template: '<App/>',
  components: { App }
})

You are missing the actual App component, you need a App.vue as well (or at least a template). Try this:

new Vue({
  el: '#app',
  template: '<div>{{title}}</div>',
  data: {title: 'success'}
})