I'm new to Vue, this may seem a basic question but I'm stuck with this problem:
I have installed Vue 3 using npm, according to the documentation:
I have included Vue to my html
file, like so:
<script src="../node_modules/vue/dist/vue.csj.js"></script>
But I get this error in the console:
vue.cjs.js:3 Uncaught ReferenceError: exports is not defined at vue.cjs.js:3 (anonymous) @ vue.cjs.js:3
I have seen some similar issues and I know it has something to do with browser compatibility and webpack; like the browser does not natively recognise import/export commands but it seems like everything is installed correctly and I don't know how to solve this issue. I couldn't find anything helpful in the documentation.
So my question is
How do I successfully install Vue and include it in my working files?
Firstly, npm install -g @vue/cli After, on commandline run vue ui and create a project
I don't think you followed that guide correctly. I would recommend you install the Vue CLI, then create your app using the cli:
$ npm install -g @vue/cli
- install cli
$ vue create my-app
However, if you don't want the CLI, I'd recommend a CDN:
<script src="https://unpkg.com/vue@next"></script>
Or you can just copy the contents of the file to your app, maybe vue.js
( https://unpkg.com/vue@next ).
And you then on your html <script src="vue.js"></script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.