当前位置:网站首页>编程式跳转
编程式跳转
2022-07-27 16:27:00 【阿山同学.】
编程式跳转
首先先创建个按钮和事件并且绑定

然后我们点击按钮之后就执行代码最后执行跳转
全代码:
<template>
<div>
<!-- 标签式跳转 -->
<h2>标签式跳转</h2>
<router-link to="/">首页</router-link>
<router-link to="/helloword">helloword</router-link>
<router-link to="/about">about</router-link>
<br>
<!-- 编程式跳转 -->
<h2>编程式跳转</h2>
<button @click="gohelloword()">3s后切换到hell oword</button>
<!-- 占位符:被替换成对应组件 -->
</div>
</template>
<script>
export default {
methods:{
gohelloword(){
var number =3;
console.log(this);
//在后台找到router
// 在vue对象中有很多$开头的属性
// vue自带属性都是$开头的
// 定时器
setInterval(()=>{
number--;
console.log(number);
if(number==0) this.$router.push("/helloword");
},1000);
}
}
}
</script>
<style lang="scss" scoped>
</style>上篇文章 :
边栏推荐
- Latex use - control the display position of tables or graphics
- Blog Garden beautification tutorial
- Mongodb learning notes (1) - install mongodb and its related configurations
- Kinect2 for Unity3D——AvatarDemo学习
- NPM's ID card and dependence
- "Testing novice encyclopedia" 5-minute quick start pytest automated testing framework
- 换行问题双保险
- Code interview of Amazon
- Resource for NS2 beginner
- Latex使用-控制表格或者图形的显示位置
猜你喜欢

Unity display Kinect depth data

Unity learning notes (rigid body physics collider trigger)

转行软测&跳槽到新公司,工作怎样快速上手?

阿里云对象存储OSS的开通和使用

What if idea successfully connects to the database without displaying the table

Typescript installation

一篇让你掌握线程和线程池,还解决了线程安全问题,确定不看看?

C#与Mysql数据库交互-Mysql配置及增删查改操作

200行代码快速入门文档型数据库MonogoDB

Product recommendation and classified product recommendation
随机推荐
MySQL learning notes (2) -- stored procedures and stored functions
ES6 learning notes (1) - quick start
Interceptor interceptor
Code interview of Amazon
Selenium automated test interview questions family bucket
Browser rendering principle analysis suggestions collection
Introduction to assembly language (1)
连续时间系统的性能分析(1)-控制系统性能指标及一二阶分析
An article allows you to master threads and thread pools, and also solves thread safety problems. Are you sure you want to take a look?
Nodejs template engine EJS
Study notes of Microcomputer Principles - general integer instructions and Applications
MongoDB学习笔记(1)——安装MongoDB及其相关配置
一个经验
PHP字符串操作
Unity display Kinect depth data
Summary of "performance test" of special test
CMD 命令
Unity learning notes (realize the conveyor belt)
MySQL 01 relational database design
Selenium自动化测试面试题全家桶
https://blog.csdn.net/weixin_50112395/article/details/124921571?spm=1001.2014.3001.5502