Vue-router the meaning of the # in the URL path

Source: Internet
Author: User

Portal Https://router.vuejs.org/zh-c ...

Router Construction Configuration Routes
  • Type:Array<RouteConfig>

    RouteConfigDefinition 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.