vue.jsHow do I create a Vue.js example app?
-
To create a Vue.js example app, first install the Vue CLI (command line interface) by running
npm install -g @vue/cliin your terminal. -
Create a new project using the Vue CLI by running
vue create my-appin your terminal, wheremy-appis the name of your app. -
Once the project is created, you can navigate to the project directory and start the development server by running
cd my-app && npm run serve. -
Create a new component in the
src/componentsfolder and add the following code to it:
<template>
<div>Hello World!</div>
</template>
<script>
export default {
name: 'MyComponent'
}
</script>
- Add the component to the
App.vuefile:
<template>
<div>
<MyComponent />
</div>
</template>
<script>
import MyComponent from './components/MyComponent.vue'
export default {
components: {
MyComponent
}
}
</script>
-
Now if you open
localhost:8080, you should see the text "Hello World!" on the page. -
To learn more about creating Vue.js apps, check out the Vue.js documentation.
More of Vue.js
- How can I use Vue.js to implement a zoomable image?
- How do I use the v-model in Vue.js?
- How can I use Vue and Chart.js to add zoom functionality to my chart?
- How do I use Yup with Vue.js?
- How can I use Vue.js mixins to create a reusable component?
- How can I build a single page application using Vue.js?
- How do I set up routing in a Vue.js application?
- How do I add a link in Vue.js?
- How can I use Vue.js to create a Progressive Web App (PWA)?
- How do I use the latest version of Vue.js?
See more codes...