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
1. Dynamic query rules The dynamic query rules ar...
1. Prepare data The following operations will be ...
Table of contents Memory Pool Overview 1. nginx d...
As shown below: As shown above, just replace it. ...
Table of contents What is a relational database? ...
Table of contents Preface Publish-Subscriber Patt...
Application example website http://www.uhuigou.net...
HTML tags have special tags to handle the title of...
Table of contents 1. Problem Description 2. Cause...
Table of contents Preface 1. Arrange the installa...
Table of contents 1. IDEA downloads the docker pl...
In MySQL, how do you view the permissions a user ...
introduction Let's start with our content. I ...
Today, when I was using VMware to install a new v...
Table of contents 1. Implementation process of qu...