There are three ways to define a component in Vue.js: directly define it in the
Copy after login
In thetag, define the component layout:
组件内容
2. Use the component factory function
Create a factory function and usedefineComponent
Auxiliary function:
import { defineComponent } from 'vue' export default defineComponent({ // 组件内容 })
3. Use classes to define components
InheritanceVue.extend
Create a class:
import Vue from 'vue' export default class MyComponent extends Vue { // 组件内容 }
Registered component:
// 在 Vue 实例中 this.$options.components.MyComponent = MyComponent
The above is the detailed content of How to define a component in vue.js. For more information, please follow other related articles on the PHP Chinese website!