当前位置:网站首页>走马灯案例
走马灯案例
2022-07-27 18:12:00 【宇智波-林中路】
字符串截取(跑马灯)
this.msg.substring(起始的索引,结束的索引【不包含结束的索引】)
this.msg.substring(起始的索引) 不传截取到最后
<body>
<div id="app">
<button @click="lang">浪起来</button>
<button @click="stop">stop</button>
<h2>{
{msg}}</h2>
</div>
</body> <script>
const app = new Vue({
el: "#app",
data: {
msg: "花有从开日,人无再少年~",
intervalId: null, //定时器id
},
methods: {
lang() {
// 如果 定时器的Id,不等于Null,就表示已经有定时器在执行了,此时,直接退出,这样就不会再开启第二个定时器了
// if (this.intervalId != null) return;
this.intervalId = setInterval(() => {
const header = this.msg.substring(0, 1);
const body = this.msg.substring(1);
this.msg = body + header;
}, 300);
},
stop() {
clearInterval(this.intervalId);
// 每当清除定时器之后,为了保证下次能够正常开启定时器,所以,需要把 intervalId 重置为null
this.intervalId = null;
},
},
});
// setInterval 都有个返回值(id)
// data中可以存放一些共享的数据,这样当示例中的任何地方,都可以直接使用 this.属性名来访问这些共享
</script>边栏推荐
- In 2019, the global semiconductor market revenue was $418.3 billion, a year-on-year decrease of 11.9%
- MySQL log error log
- Software test interview question: if a string is known as "hello_world_yoyo", how to get a queue ["hello", "world", "yoyo"]
- 创新案例 | 本地生活服务数字化,高德品牌升级的增长战略
- Huiding Technology: the acquisition of NXP vas business has been completed
- 洋葱集团携手OceanBase实现分布式升级,全球数据首次实现跨云融合
- LabVIEW学习笔记五:按钮按下后无法返回原状
- Summary of simple topics
- 【防抖与节流】
- What are the apps of regular futures trading platforms in 2022, and are they safe?
猜你喜欢

浅析即时通讯移动端 IM 开发中登录请求的优化

如何监控NVIDIA Jetson的的运行状态和使用情况

Scrollintoview realizes simple anchor location (example: select city list)
![Laboratory management system implemented by SSM framework +jsp [source code + database + system paper]](/img/2e/64af546c58f3dc517cdae304daa671.png)
Laboratory management system implemented by SSM framework +jsp [source code + database + system paper]

Understand │ what is cross domain? How to solve cross domain problems?
![Leetcode:1498. Number of subsequences that meet the conditions [sort + bisection + power hash table]](/img/a9/de68e8affcb6b84e82cf344e7254e3.png)
Leetcode:1498. Number of subsequences that meet the conditions [sort + bisection + power hash table]

Mlx90640 infrared thermal imager temperature sensor module development notes (VII)

Jetpack Compose 性能优化指南——编译指标

人家这才叫软件测试工程师,你那只是混口饭吃(附HR面试宝典)

海康设备接入EasyCVR,出现告警信息缺失且不同步该如何解决?
随机推荐
MySQL log error log
Innovative cases | the growth strategy of digitalization of local life services and upgrading of Gaode brand
Homology and cross domain
[rctf2015]easysql-1 | SQL injection
DP (dynamic programming)
SQL高级技巧CTE和递归查询
Is it safe for CICC fortune to open an account? What is the use of opening an account
Koin simple to use
2022-07-19 advanced network engineering (XX) BGP route optimization, route optimization analysis one by one
What app should individuals use for stock speculation to be safer and faster
Anfulai embedded weekly report no. 275: 2022.07.18--2022.07.24
[efficiency] abandon notepad++, this open source substitute is more awesome!
【程序人生】“阶段总结“-不甘平凡
创新案例 | 本地生活服务数字化,高德品牌升级的增长战略
Download of MySQL driver jar package -- nanny tutorial
软件测试面试题:已知一个字符串为“hello_world_yoyo”, 如何得到一个队列 [“hello“,“world“,“yoyo“]
Preprocessing and macro definition
Analysis on the optimization of login request in IM development of instant messaging mobile terminal
未定义变量 “Lattice“ 或类 “Lattice.latticeEasy“(Matlab)
从0开始写bootloader