require em Vue.js Component

Asked

Viewed 82 times

0

Good afternoon I can’t use the "Next" require in the Vue Component file. How to resolve 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 the :

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

Thank you for your attention!!

1 answer

0

I believe require would only work on Node friend (if you’re not using an import lib), try using es6 syntax:

import axios from 'axios';

  • Hi, did not work, the error reported is "Uncaught Syntaxerror: Unexpected Identifier"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.