How to Create and Use Component in Vue JS Cli?
You can learn how to create own component in vue npm. we will use vue cli to create vue js setup and then we will create own custom component in vue js. you can simply create vue cli component with laravel or codeigniter app.
We will learn from scratch to create vue component. so first we will create vue js project using vue cli. then we will create Exmaple.vue component and import Example component in app. So let's see bellow steps:
Create Vue Project
vue create my-vue-library
Create Vue Component
src/components/Example.vue
<template>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">My Example</div>
<div class="card-body">
Welcome to ItSolutionStuff.com
</div>
</div>
</div>
</div>
</div>
</template>
<script>
export default {
mounted() {
console.log('Component mounted.')
}
}
</script>
Update App.vue
src/App.vue
<template>
<div id="app">
<Example></Example>
</div>
</template>
<script>
import Example from './components/Example.vue'
export default {
name: 'app',
components: {
Example
}
}
</script>
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Vue JS Get Dropdown Selected Value Example
- Laravel Vue Dependent Dropdown Example
- Vue Toastr Notifications Example Code
- File Upload using Vue js Axios PHP Example
- How to Replace String in Vue JS?
- How to Open a Link in a New Tab in Vue JS?
- How to Use setTimeout Function in Vue JS?
- Laravel Vue Router Example From Scratch
- Laravel Vue JS Image Upload Example
- Laravel Vue JS Axios Post Request Example
- Laravel Vue JS Infinite Scroll Example with Demo
- Laravel Vue JS Pagination Example with Demo
- Dynamic Dependent Dropdown using VueJS and PHP
- Laravel 5.6 - Dynamic Ajax Autocomplete using Vue.js