Home > Web Front-end > Vue.js > How to jump to another page in vue

How to jump to another page in vue

藏色散人
Release: 2023-01-13 00:45:33
Original
29720 people have browsed it

How to implement vue to jump to another page: 1. Add a jump function in the a tag; 2. Add the jump url to $router; 3. Through the combination of "path query" Just pass the parameters.

How to jump to another page in vue

The operating environment of this article: windows7 system, vue2.5.17 version, DELL G3 computer.

How to jump to another page in vue?

Solution for vue to jump from one page to another and carry parameters

1. Requirements:

Click on the mall to jump to the commercial list

Solution:

meta page:

a tag Adding a jump function

<a class="orderBtn1 sIRicon2" href="javascript:void(0);" rel="external nofollow" @click="toMallInfo(&#39;M000989&#39;)"><i class="sIRicon"></i>商场</a>
Copy after login
  toMallInfo: function(mallCode){
    this.$router.push({
     path: &#39;/propertyInfo/mall/mallList&#39;,
     // name: &#39;mallList&#39;,
     query: {
      mallCode: &#39;M000989&#39;
     }
    })
   },
Copy after login

will add the jump url to $router.

Adding / at the front of the url in the path means it is in the root directory. If it is not added, it is a sub-route.

Pass parameters through the combination of path query

----

Jump page to receive parameters

 created(){
   this.getParams()
  },
methods :{getParams(){
    // 取到路由带过来的参数
    const routerParams = this.$route.query.mallCode
    // 将数据放在当前组件的数据内
    this.mallInfo.searchMap.mallCode = routerParams;
    this.keyupMallName()
   }
  },
  watch: {
   &#39;$route&#39;: &#39;getParams&#39;
  }
Copy after login

Solution! ! !

Recommended learning: "vue tutorial"

The above is the detailed content of How to jump to another page in vue. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
vue
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template