A
A
Arktares2018-03-18 16:28:00
Vue.js
Arktares, 2018-03-18 16:28:00

Vue cdn, component from file?

When connecting Vue via NPM and working with components, everything is clear. The component can be connected from a file, everything works.
But when connecting Vue via CDN, it is not possible to connect the component from the file.
Here is an example code:

import firstComponent from 'firstComponent.js';

new Vue({
    el: '#app',
    components: {
        firstComponent
    },
});

Gives the error "SyntaxError: import declarations may only appear at top level of a module".
I tried to add the type="module" attribute in the script tag of the included js file, but then nothing works at all.
Tell me what's the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question