Vue页面跳转传递参数及接收

news/2024/7/10 0:45:46 标签: vue, vue.js, 前端, mysql, 数据库

这里给大家推荐一款免费迭代 二开便捷的商城项目:源码直通车>>>

最近接触了vue项目,这里记录一下vue跳转到下一页面携带参数的两种方式。

典型应用场景:列表页跳转到详情页

一、配置路由

文件路径:src/router/config.php

import Vue from 'vue'
import Router from 'vue-router'

import classify from '.././components/classify/classify.vue'

import classifyChild from '.././components/classify/classifyChild.vue'

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/classify',
      name: ' classify',
      component: classify
    },
    {
      path: '/classify/classifyChild',
      name: 'classifyChild',
      component: classifyChild
    },
    
  ]
})

二、页面跳转及传参

//方式一
<router-link :to="{name:'classifyChild',params:{id:item.id}}">
    <button>跳转</button>
</router-link>

//方式二
<router-link :to="{path:'/classify/classifyChild',query:{id:item.id}}">
    <button>跳转</button>
</router-link>

三、参数接收

//对应于方式一
let id=this.$route.params.id;

//对应于方式二
let id=this.$route.query.id;

 

 

 


http://www.niftyadmin.cn/n/908956.html

相关文章

试用Jenkins 2 的 Pipeline 项目

目前Jenkins最新的版本是2.7&#xff0c;现在试用一下pipeline类型的项目&#xff0c;本来想构建一个1.651版本的Jenkins为例&#xff0c;无奈大陆的网络 访问github不稳定&#xff0c;只好改为简单的工程。 目前有一个代码仓库地址&#xff1a; https://github.com/wangzy23/j…

Vue路由和跨域配置冲突问题

这里给大家推荐一款免费迭代 二开便捷的商城项目&#xff1a;源码直通车>>> 我之前有篇博客谈论过vue调用接口&#xff0c;会出现跨域的问题 https://blog.csdn.net/fate_sky8521/article/details/89948841 根据之前配置可以调用接口了&#xff0c;但是会有一个新的…

集合用例

1. map用法示例&#xff1a; set - get &#xff1b; 对象 - 对象的引用 1 public List<OrganBatchFlowDTO> selectCompareList(2 Req_compareInfo_query record) {3 4 /** 1、查询日切流水表&#xff0c;得到记录*/5 List<OrganBatc…

jeDate带时分秒的日期控件使用

因项目需要&#xff0c;限时抢购需要个带时分秒的时间插件&#xff0c;选择了下&#xff0c;敲定为jeDate 下面记录一下使用步骤 JS和样式CSS引入 <link type"text/css" rel"stylesheet" href"test/jeDate-test.css"><link type&quo…

通过HttpURLConnection下载图片到本地--批量下载

一.背景说明 这篇文章讲述的是批量下载附件&#xff0c;在上一篇文章中&#xff0c;介绍了下载单个附件&#xff08;上一篇文章&#xff09;。 二.实现思路 主要的实现思路&#xff1a;创建文件夹->文件夹中创建需要下载的文件->压缩文件夹->下载zip->删除文件夹 三…

tp5时间搜索

前端&#xff1a; <div class"timeCon"><div class"timeCon-1"><input type"text" name"start_time" id"beginTime1" lay-verify"required" placeholder"请选择开始时间" class"l…

With great power comes great responsibility

★1.我最擅长&#xff01;★ 我认为每个人一定都有自己最擅长的事情。对&#xff0c;就是那种只有你做得好&#xff0c;如果现在你还没有找到&#xff0c;就一定不要怕花时间去发掘自己&#xff01;毕竟这个世界上&#xff0c;除了你自己&#xff0c;还有谁能把这件事做得最好呢…

ThinkCMF报错未定义变量vo

最近接手了公司的一个ThinkCMF项目&#xff0c;刚开始就遇到了一个坑 找了一圈&#xff0c;原来是没引入portal:categories方法 通过以下代码引入即可 <taglib name"app\portal\taglib\Portal,app\portal\taglib\Partner,app\portal\taglib\Product"/>