若依VUE 从一个页面跳转另一个页面并携带参数

前言

由于火狐浏览器某些版本不支持 :to写法,测试后把同事的代码优化一下

代码

第一个页面

html 复制代码
		<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-edit" @click="toWinWorker(scope.row, queryParams.createTime)">
              打卡记录
              <!--<router-link :to="'/hcp/windowWorker/index/' + scope.row.winId + '/' + queryParams.createTime" class="link-type" 			size="mini" type="text" style="color: #1890ff">打卡记录</router-link>-->
            </el-button>
          </template>
        </el-table-column>
javascript 复制代码
	/*打卡记录*/
    toWinWorker(row, createTime) {
      const winId = row.winId;
      this.$router.push("/hcp/windowWorker/index/" + winId + "/" + createTime);
    },

跳转路由js

javascript 复制代码
  {
    path: '/hcp',
    component: Layout,
    hidden: true,
    children: [
      {
        path: 'windowWorker/index/:id/:date',
        component: (resolve) => require(['@/views/hcp/windowWorker/index'], resolve),
        name: 'WindowWorker',
        meta: {title: '工作人员打卡记录', icon: ''}
      }
    ]
  },

另一个页面

javascript 复制代码
	// 把携带的参数放到queryParams查询参数里
	created() {
		this.queryParams.winId = this.$route.params && this.$route.params.id;
	    this.queryParams.createTime = this.$route.params && this.$route.params.date;
	},
相关推荐
!win !1 小时前
前端跨标签页通信方案(下)
前端·javascript
f***45321 小时前
基于SpringBoot和PostGIS的各省与地级市空间距离分析
android·前端·后端
编码追梦人2 小时前
从 “手忙脚乱“ 到 “行云流水“:华为云 DevUI 与 MateChat 如何让前端开发飞起来
前端·华为云
用户47949283569152 小时前
TypeScript 简史:它是怎么拯救我的烂代码的
javascript·typescript
S***H2832 小时前
前端动画实现经验,性能优化与兼容性
前端
用户47949283569153 小时前
只有前端 Leader 才会告诉你:那些年踩过的模块加载失败的坑(二)
javascript
xw53 小时前
前端跨标签页通信方案(下)
前端·javascript
zzlyx993 小时前
IoTSharp前端VUE采用npm run build编译提示require() of ES Module 出错
前端·vue.js·npm
全栈技术负责人3 小时前
拒绝“无法复现”:前端全链路日志排查实战手册
前端·全链路·问题排查思路
加洛斯3 小时前
前端小知识003:JS中 == 与 === 的区别
开发语言·前端·javascript