Detailed description of SPA single page application in vue, vuespa
I. SPA Overview
SPA (single page application) single page application, in a completed application or site, there is only one complete html page, this page has a container, you can insert the code snippet to the container.
How SPA works:
Eg: http: // 127.0.0.1/index.html #/start
① Parse the complete page according to the url in the address bar: index.html
Index.html
② According to the url resolved # in the address bar, the route address is start.
Based on the route address, go to the configuration object of the route address in the current application configuration to find the page address of the template corresponding to the route address
Initiate an asynchronous request to load the page address
③ Load the requested data to the specified container
Ii. basic steps for implementing a SPA through VueRouter
① Introduce the corresponding vue-router.js (the file I have uploaded to my file)
② Specify a container for storing code snippets
<router-view></router-view>
③ Components required for business creation
④ Configure the routing dictionary
Configuration object of each route address (which page to load ...)
const myRoutes = [ {path:'/myLogin',component:TestLogin}, {path:'/myRegister',component:TestRegister} ] const myRouter = new VueRouter({ routes:myRoutes }) new Vue({ router:myRouter })
⑤ Test
Enter different routing addresses in the address bar to confirm whether the corresponding <! Doctype html>
<Html>
<! Doctype html>
The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.