use <div id="app"> <router-link to='home'>Home</router-link> <router-link to='about'>About</router-link> <router-view a=1><router-view/> </div> router-view component export default { //Functional components do not have this, cannot be new, and do not have two-way data binding. They are usually used less frequently and are more suitable for displaying detail pages because the detail pages only display and do not modify or perform other operations. Functional components are lighter than stateful components. functional:true, render(h,{parent,data}){ parent represents the parent component app data is an inline attribute (a=1 in the above code) and can also be passed using prop let route = parent.$route; let depth = 0; data.routerView = true; while(parent){ //$vnode refers to the virtual dom. If there is a virtual dom on the app and the routerView on this virtual dom is true if (parent.$vnode && parent.$vnode.data.routerView){ depth++; } parent = parent.$parent; } let record = route.matched[depth]; if(!record){ return h(); } return h(record.component, data); } } Implementation of router-link export default { props:{ to:{ type:String, required:true }, tag:{ type:String } }, render(h){ let tag = this.tag || 'a'; let handler = ()=>{ this.$router.push(this.to); } return <tag onClick={handler}>{this.$slots.default}</tag> } } This is the end of this article about the implementation principles of Vue router-view and router-link. For more relevant Vue router-view and router-link content, 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:
|
<<: Python MySQL database table modification and query
>>: Linux command line quick tips: How to locate a file
Table of contents 1. Description of functions in ...
Download the image (optional step, if omitted, it...
Table of contents 1. Subquery definition 2. Subqu...
1. Download the installation package -Choose the ...
Platform deployment 1. Install JDK step1. Downloa...
1. The color of the scroll bar under xhtml In the ...
When we design a page, we often need to center th...
I won't say much nonsense, let's just loo...
<br />In one year of blogging, I have person...
Table of contents Preface Source code Where do I ...
As shown below: XML/HTML CodeCopy content to clip...
MySQL slow log is a type of information that MySQ...
Table of contents Tutorial Series 1. Install Mari...
This article shares the specific code of the canv...
MySQL 8.0.20 installation and configuration super...