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
Effect picture: html: <div class='site_bar...
This article originated from my complaints about ...
Previously, my boss asked me to make a program th...
Table of contents Canvas related documents Effect...
This article shares the specific code for impleme...
Table of contents 1. Demand 2. Database Design 3....
1. The difference between forward proxy and rever...
<br /> In the first and second parts, we int...
Introduction When the MySQL InnoDB engine queries...
In order to prevent non-compliant data from enter...
The LIKE operator is used in the WHERE clause to ...
Prepare: Define a teacher table and a student tab...
MySQL reports an error when executing multi-table...
The JSON format field is a new attribute added in...
mysql-5.7.20-winx64.zipInstallation package witho...