当前位置:网站首页>Riding lantern case
Riding lantern case
2022-07-27 20:56:00 【Yuzhibo Linzhong Road】
String interception ( Running lights )
this.msg.substring( Starting index , End index 【 Does not contain the ending index 】)
this.msg.substring( Starting index ) Don't pass interception to the end
<body>
<div id="app">
<button @click="lang"> Wave up </button>
<button @click="stop">stop</button>
<h2>{
{msg}}</h2>
</div>
</body> <script>
const app = new Vue({
el: "#app",
data: {
msg: " Flowers bloom from the sun , No man is ever young ~",
intervalId: null, // Timer id
},
methods: {
lang() {
// If Timer Id, It's not equal to Null, It means that there is already a timer executing , here , immediate withdrawal , So you won't start the second timer
// 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);
// Whenever the timer is cleared , To ensure that the timer can be started normally next time , therefore , Need to put intervalId Reset to null
this.intervalId = null;
},
},
});
// setInterval All have a return value (id)
// data Some shared data can be stored in , So when anywhere in the example , Both can be used directly this. Property name to access these shares
</script>边栏推荐
猜你喜欢

关于栈迁移的那些事儿
![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]

Using dataX to realize efficient synchronization of MySQL data

Hexagon_V65_Programmers_Reference_Manual(6)

knife4j通过js动态刷新全局参数

JVS私有化部署启动失败处理方案

JVS基础介绍

Arduino development (II)_ RGB light control method based on Arduino uno development board

【深度学习】Pytorch Tensor 张量

MySQL驱动jar包的下载--保姆教程
随机推荐
《SRE:Google运维解密》读后有感
14天鸿蒙设备开发实战-第七章 设备联网上云 学习笔记
How to solve the problem of missing alarm information and synchronization when Haikang equipment is connected to easycvr?
Ten year test old bird talk about mobile terminal compatibility test
用户和权限修改用户密码
How to monitor the running status and usage of NVIDIA Jetson
vi工作模式(3种)以及模式切换(转换)
如何解决tp6控制器不存在:app\controller\Index
【深度学习】Pytorch torch.autograd 自动差分引擎
金仓数据库 KingbaseES异构数据库移植指南 (3. KingbaseES移植能力支撑体系)
R语言使用dplyr包左连接两个dataframe数据(left join)
Download of MySQL driver jar package -- nanny tutorial
认识传输介质通信方式
用户组织架构的管理
走马灯案例
knife4j通过js动态刷新全局参数
Hexagon_V65_Programmers_Reference_Manual(9)
[numpy] array index and slice
JVS基础介绍
Lennix Lai, OKx financial market director: Web3 is a revolution