首页 > 其他分享 >通过代码跳转路由

通过代码跳转路由

时间:2022-11-18 22:58:43浏览次数:48  
标签:smoothing home 代码 replace 跳转 router font 路由

<template>
  <div id="app">
    <button @click="toHome">首页</button>
    <button to="/about"  @click="toAbout">关于</button>
    <!-- 相当于占位符 -->
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: 'App',
    methods:{
      toHome(){
        this.$router.push('/home')
        //地址不能前进后退
        //this.$router.replace('/home')
      },
      toAbout(){
        this.$router.push('/about')
        //this.$router.replace('/about')
      }
    }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

  

标签:smoothing,home,代码,replace,跳转,router,font,路由
From: https://www.cnblogs.com/ixtao/p/16905167.html

相关文章