vue js component on create code example
Example 1: component in vue
// Define a new component called button-counter
Vue.component('button-counter', {
data: function () {
return {
count: 0
}
},
template: '<button v-on:click="count++">You clicked me {{ count }} times.</button>'
})
Example 2: vue js app component
// main.js
import { createApp } from 'vue'
import App from './App.vue'
import 'YourComponent' from 'YourFileOrLibrary';
const app = createApp(App);
app.component('yourComponent', YourFileOrLibrary);
// ...