Portal Https://router.vuejs.org/zh-c ...
Router Construction Configuration Routes
Type:Array<RouteConfig>
RouteConfig
Definition of the type:
DECLARE type routeconfig = {path:string; Component?: component; Name?: string;//named route components?: {[name:string]: Component}; //named View component redirect?: string | Location | Function; Props?: Boolean | string | Function; Alias?: String | array<string>; Children?: array<routeconfig>; //nested routines by Beforeenter?: (To:route, From:route, Next: Function) = void; meta?: any; //2.6.0+ casesensitive?: boolean; //matching rules are case-sensitive? (default: false) Pathtoregexpoptions?: Object; //Compile regular options}
Mode
Type:string
Default value:"hash" (浏览器环境) | "abstract" (Node.js 环境)
Optional values:"hash" | "history" | "abstract"
To configure the routing mode:
hash
: Use URL hash value for routing. Supports all browsers, including browsers that do not support the HTML5 history Api.
history
: Relies on the HTML5 history API and server configuration. View HTML5 history mode.
abstract
: Supports all JavaScript runtime environments, such as node. JS Server side. If no browser API is found, the route is automatically forced into this mode.
Now 3 modes of front-end routing, commonly used is the hash mode (address has # number) and history mode (address and real request no difference)
Other than that
#
Is the hash symbol used by vue-router
#!
Is the hash symbol used by the Angularjs Route
It doesn't matter, there is # on the line (browser will not happen page jump)
#是hash模式
History mode without the # number,
But deploy to the server.
Hash mode does not appear to refresh the 404 issue:
History mode if you refresh or connect directly to a page, you will be prompted 404 ...
In the traditional way, the backend program actually generates a file, and the connection request can really find a file.
This single-page style has only one HTML, nor does the backend program automatically generate files.
So if you use the history mode, you need to configure the virtual path when you deploy to the server
Point to the index.html file if the resource is not requested
Vue-router the meaning of the # in the URL path