当前位置:网站首页>编程式跳转
编程式跳转
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>上篇文章 :
边栏推荐
- 200行代码快速入门文档型数据库MonogoDB
- 一个经验
- Selenium自动化测试面试题全家桶
- During the interface test, connect to the database and back up, restore and verify the data source
- express
- v-if,v-else,v-for
- 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?
- Resource for NS2 beginner
- 换行问题双保险
- 收下这份实操案例,还怕不会用Jmeter接口测试工具
猜你喜欢

Introduction to assembly language (1)

Automatic testing of Web UI: Selenium syntax explanation is the most complete in the history

MongoDB

npm 基本使用

自控原理学习笔记-系统稳定性分析(1)-BIBO稳定及Routh判据

专项测试之「 性能测试」总结

ES6学习笔记(1)——快速入门

Big enemies, how to correctly choose the intended enterprises in the new testing industry?

连续时间系统的性能分析(2)-二阶系统性能改善方式PID,PR

Nodejs template engine EJS
随机推荐
PHP字符串操作
Performance analysis of continuous time systems (2) - second order system performance improvement methods PID, PR
Resource for NS2 beginner
NPM's ID card and dependence
Latex use - subfigure vertical graphics
阿里云对象存储OSS的开通和使用
Nodejs template engine EJS
asp.net 的经验
asp. Net experience
2022备战秋招10W字面试小抄pdf版,附操作系统、计算机网络面试题
微机原理学习笔记-通用整数指令及应用
v-if,v-else,v-for
"Testing novice encyclopedia" 5-minute quick start pytest automated testing framework
During the interface test, connect to the database and back up, restore and verify the data source
Matrix of shell programming -- it's cute and cool
MySQL学习笔记(2)——存储过程与存储函数
Hash、Set、List、Zset、BitMap、Scan
express get/post/delete...请求
Day 3 of leetcode question brushing
Role authorization --- complete the addition and deletion of secondary menus by adding and deleting primary menus
https://blog.csdn.net/weixin_50112395/article/details/124921571?spm=1001.2014.3001.5502