This article shares the specific code of Vue to achieve a simple marquee effect for your reference. The specific content is as follows Rendering Code html <div id="app"> <button @click="start">Start</button> <button @click="stop">Stop</button> <p>{{msg}}</p> </div> vue var app = new Vue({ el: "#app", // indicates that the new vue instance we are creating now will control the area on the page // data is the m in mvvm, which is used to store the data of each page data:{ msg: "Lock on Li Jiaqi's live broadcast room at 19:30 tonight, don't miss it~", timer: null }, methods:{ start(){ // Use the timer text to scroll on time // Arrow function can solve the this pointing problem // The this pointing in the arrow function is consistent with that outside the function // The timer is turned on only when timer is not null if (this.timer != null) return; this.timer = setInterval(() => { // Get the first character var startMsg = this.msg.substring(0,1); // Get all the characters that follow var endMsg = this.msg.substring(1); // Reassemble msg this.msg = endMsg + startMsg; },400) }, stop(){ clearInterval(this.timer); // You can print the timer after clearing the timer yourself, and you will find that it is not null, so you need to reassign this.timer = null; } } }); The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Examples of common Nginx misconfigurations
>>: How to extract string elements from non-fixed positions in MySQL
1. What is the use of slow query? It can record a...
This article example shares the specific code of ...
Downloaded an es image from docker hub, version 6...
Table of contents mousejoint mouse joint distance...
Table of contents What is a relational database? ...
Introduce two methods to view MySQL user permissi...
1. Add a new user Only allow local IP access crea...
The Explain command is the first recommended comm...
Table of contents 1. CentOS7+MySQL8.0, yum source...
Table of contents Problem Description Rendering T...
Table of contents 1. Basic conditions for databas...
1. Changes in MySQL's default storage engine ...
Table of contents 1. Easy to read code 1. Unified...
1. Command Introduction The watch command execute...
1. Create a new user wwweee000 [root@localhost ~]...