美国服务器的vue中怎么实现按钮跳转

已关闭留言

美国服务器的vue中实现按钮跳转的方法:1、在html文件中使用button标签设置按钮并添加点击事件;2、在vuemethods中添加方法实现页面跳转;3、通过浏览器查看设计效果即可。

具体操作方法:

1、在html文件中使用“button”标签设置一个按钮并添加一个“@click”点击事件。

<button @click=”register”>登录</button>

2、在vue中方法需要写在methods里,因此在methods中添加以下跳转方法实现页面跳转即可。

register () {

//跳转到上一次浏览的页面

this.$router.go(-1)

//指定跳转的地址

this.$router.replace(‘/将要跳转的路由名称‘)

//指定跳转的路由的名字下

this.$router.replace({name:’指定路由名称‘})

//通过push进行跳转

this.$router.push(‘/将要跳转的路由名称‘)

}

3.最后可通过浏览器方式阅读html文件查看设计效果。