require in component of vue.js

0

Good afternoon, I can not use the "axios" require in the vue component file. How to solve this? the file in question is home.js:

const axios = require('axios');
Vue.component('home-page', {
    template: '
        <div>
           <input type='text' v-model='nome' >{{nome}} 
        </div>
    ',

    data: function () {

        return {
            nome: "teste",
        }
    },
    mounted: function () {

    }
})

The error that appears is:

"Uncaught ReferenceError: require is not defined at home-page-component.js:1"

No more, thanks for the attention !!

    
asked by anonymous 02.08.2018 / 18:44

1 answer

0

I believe that require would only work on the friend node (if you are not using an import lib), try using the es6 syntax:

import axios from 'axios';
    
02.08.2018 / 19:06