Example: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>slot practice</title> <script src="../../js/vue.js"></script> </head> <body> <div id="app"> <div style="border: 7px solid blueviolet;"> <h2>Parent Component</h2> <cpn> <!-- Add an element to the specified slot position --> <button slot="left">Button</button> <input type="text" slot="right" placeholder="This is an input box..."></input> </cpn> </div> </div> <template lang="" id="cpn"> <div style="border: 6px solid green;"> <h2>Subcomponents</h2> <!-- Define three slots in the subcomponent, and the values in the slots are default values--> <slot name="left">Left</slot> <slot name="mediate">Medium</slot> <slot name="right">Right</slot> </div> </template> <script> new Vue({ el:'#app', components:{ cpn:{ template:'#cpn', } } }) </script> </body> </html> The effect is as shown below:
This is the end of this article about the usage of slots in Vue. For more information about the usage of slots in Vue, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Using the outline-offset property in CSS to implement a plus sign
>>: Implementation of master-slave replication in docker compose deployment
I am using the Ubuntu 16.04 system here. Installa...
Cell -- the content of the table Cell margin (tabl...
Copy code The code is as follows: <style type=...
Navigation bar creation: Technical requirements: ...
I have several tomcats here. If I use them at the...
Preface As we all know, HTML5 belongs to the Worl...
Preface Golang provides the database/sql package ...
1. Docker startup problem: Problem Solved: You ne...
nginx Nginx (engine x) is a high-performance HTTP...
Table of contents MySQL basic common commands 1. ...
Preface In the previous article, we mainly learne...
Preface: In some previous articles, we often see ...
Install boost There are many ways to call C/C++ f...
Let me start with a question: When writing an HTM...
This article example shares the specific code of ...