The difference between vue slot and router-view

slot provides placeholders, as is the case with router-view. What is the essential difference between the two? What is the applicable scenario of the difference?

Mar.01,2021

router-view is a functional component, it is a component of , and the important thing is said three times , which is used to render the view component to which the path matches. The core concept is: path matching and render view components .

slot is actually an abstract element, somewhat similar to template, design idea and somewhat similar to polymorphism in object-oriented, which needs to be defined separately for an item in a component, so solt should be used. The core concept is that an item in a component may be an element or just a text.

example:
Project requires a modal box, including success and failure, in which the modal box has the difference between the copy and the background picture, then the modal box can be regarded as a component, while the copy and background picture can be used slot.

I hope it will be helpful to you!


there is no relationship between the two. Router-view is used for routing navigation, and slot is used for parent-child component content distribution, which can be understood as a slot, and the relevant content can be distributed to the slot location of the child component.


router-view is used for routing navigation, and
slot is generally used for parent-child component distribution.


the two have nothing to do with each other. Barely speaking, v-if , < component: is= "xx" > can also provide the role of placeholder.

< hr >

router-view is associated with browser access records.
slot inserts the content defined in the parent component into the structure of the child component (yes, the content of slot is the parent component).


they are not comparable!


you said so much but didn't tell the essential difference at all

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b32187-2be02.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b32187-2be02.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?