This article shares the specific code of Vue to achieve a simple effect of a marquee for your reference. The specific content is as follows 1. Marquee effect Description: Click the "Support" button to make the text float to the left, then click the "Pause" button to stop the current floating 2. Complete code (Note: the vue.js file needs to be introduced in the code. This file is introduced according to the directory location. The specific location is commented in the code) <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Marquee</title> <!-- Import vue.js file--> <script src="../vue.js"></script> <style type="text/css"> #app{ padding: 20px; } </style> </head> <body> <div id="app"> <button @click="run">Support</button> <button @click="stop">Pause</button> <h3>{{msg}}</h3> </div> <script> new Vue({ el:"#app", data:{ msg:"Friends, friends, I love you, just like mice love rice~~~!", timer:null //Define the timer on data, the default value is null }, methods:{ run(){ // If timer has been assigned, return if(this.timer){return}; this.timer = setInterval(() => { // msg is split into arrays var arr = this.msg.split(''); // shift deletes and returns the deleted one, push adds to the end // put the first element of the array at the end arr.push(arr.shift()); // arr.join('') connects the array into a string and copies it to msg this.msg = arr.join(''); },100) }, stop(){ //Clear timer clearInterval(this.timer); //After clearing the timer, you need to set the timer to null again this.timer = null; } } }) </script> </body> </html> 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:
|
<<: Each time Docker starts a container, the IP and hosts specified operations
>>: MySQL online DDL tool gh-ost principle analysis
Create a project directory mkdir php Create the f...
1. Big Data and Hadoop To study and learn about b...
Table of contents Overview 1. Hook calling order ...
Preface The master-slave replication relationship...
Deployment environment: Installation version red ...
1. Software Download MySQL download and installat...
Table of contents umask Umask usage principle 1. ...
SVN is the abbreviation of subversion, an open so...
Recently, when doing homework, I needed to nest a ...
【Problem Analysis】 We can use the chown command. ...
1 method is a property that specifies how data is ...
This article aims to clarify the relationship bet...
Table of contents Preface 【undo log】 【redo log】 【...
Given an array [1,8,5,4,3,9,2], write an algorith...
Do you know what fonts are used in the logo desig...