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/cli
in your terminal. -
Create a new project using the Vue CLI by running
vue create my-app
in your terminal, wheremy-app
is 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/components
folder 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.vue
file:
<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 implement pinch zoom functionality in a Vue.js project?
- How do I get the z-index to work in Vue.js?
- How do I use Yup with Vue.js?
- How do I use the v-if directive in Vue.js?
- How do I unmount a Vue.js component?
- How do I set a z-index in Vue.js?
- How can I use Vue.js to parse XML data?
- How do I integrate Yandex Maps with Vue.js?
- How can I use Vue.js to implement image zooming on my website?
- How to use a YAML editor with Vue.js?
See more codes...