温馨提示×

vue中页面跳转的方式有哪些

养鱼的猫咪
434
2021-03-29 14:52:22
栏目: 编程语言

在vue中实现页面跳转的方式有:1.使用a标签跳转;2.使用this.$router.push()函数跳转;3.使用router-link标签跳转;

vue中页面跳转的方式有哪些

在vue中实现页面跳转的方式有以下几种

1.使用a标签跳转

<a href="https://www.baidu.com"><button>点击跳转</button></a>

2.使用this.$router.push()函数跳转

<template>

 <div id='test'>

 <button @click='goTo()'>点击跳转</button>

 </div>

</template>

<script>

 export default{

 name:'test',

 methods:{

 goTo(){

 this.$router.push('/testDemo');

3.使用router-link标签跳转

<router-link :to="{path:'testDemo',query:{setid:123456}}">

 <button>点击跳转</button>

</router-link>


0