In Vue, we can define (register) local components ourselves To define a component name: var ComponentA = { /* ... */ } var ComponentB = { /* ... */ } Then define the components you want to use in the components option: new Vue({ el: '#app', // Component center components: { // When rendering a local registered component at the view layer // component-a: the name you want to use when calling at the view layer // ComponentA: Local registered component name 'component-a': ComponentA, 'component-b': ComponentB } }) Call the local component in the view layer: <div id="app"> <component-a></component-a> <component-b></component-b> </div> For example: <body> <div id="app"> <component-a></component-a> <component-b></component-b> </div> <script src="./js/vue.js"></script> <script> let componentA = { template:` <p>I am a local component 1</p> ` } let componentB = { template:` <p>I am a local component 2</p> ` } let vm = new Vue({ el:'#app', data:{ }, components:{ "component-a":componentA, "component-b":componentB } }) </script> The output is: You may also be interested in:
|
<<: Perfect solution to Google Chrome autofill problem
Why? The simplest way to put it is that pixels are...
This article shares the specific code of JS canva...
Table of contents 1. Relationship between parent ...
background The amount of new data in the business...
1. Use the speed control function to control the ...
First of all, we know that this effect should be ...
Today I have a question about configuring MySQL d...
We all know that data is priceless. If we don’t b...
Many web pages have small triangles in their navi...
1. Download the required packages wget -P /usr/lo...
This article shares the specific code of Vue usin...
1. Software Introduction VirtualBox VirtualBox is...
I wonder if you are like me, a programmer who arr...
In actual Web development, inserting images, incl...
Effect picture (the border color is too light, pu...