<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