VUE路由跳转

本文介绍了VUE中使用routerindex.js配置路由的方法,并通过实例展示了不同方式的路由跳转,包括文字链接、a标签及router-link等。此外,还探讨了各种跳转方式的区别。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

VUE路由跳转

router index.js

import Vue from 'vue'
import Router from 'vue-router'
import table from '@/views/personal/table'
Vue.use(Router)

//在路由添加的地方 添加路由信息
{
	path: '/table',
    meta: { title: '表格', icon: 'el-icon-set-up' },
    component: () => import('@/views/personal/table'),
},

目标组件 other.vue

<template>
    <div>
      <p>
        文字链接:
        <el-link href="/table" :underline="false" type="success">表格</el-link>
      </p>
      <p style="margin: 20px 0">
        a标签:
        <a href="/table" style="color: rgb(19, 206, 102)">表格</a>
      </p>
      router-link 不带参数 普通跳转:
      <router-link to="/table" style="color: rgb(19, 206, 102)">表格</router-link>
      <p class="tooltip">
        文字链接跳转比a标签慢很多,文字链接类似强刷。router-link是只跳转,不刷新页面
      </p>
    </div>
</template>

<script>
export default {
  name: "otherIndex",
};
</script>

点击按钮,打开一个新的页面

   let url = "http://localhost:9527/#/vertical-add";//这个是绝对地址,浏览器上的地址
      var iWidth = 1500; //弹出窗口的宽度;
      var iHeight = 845; //弹出窗口的高度;
      var iTop = (window.screen.height - 10 - iHeight) / 2; //获得窗口的垂直位置;
      var iLeft = (window.screen.width - 10 - iWidth) / 2; //获得窗口的水平位置;
      window.open(
        url,
        "_blank" , "height=" + iHeight +",innerHeight=" + iHeight + ",width=" + iWidth +
        ",innerWidth=" + iWidth + ",top=" + iTop + ",left=" + iLeft +","
      );

点击按钮,关闭当前页面

window.close();
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值