Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Vue to make a simple random click list

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the knowledge of "how to use Vue to make a simple random click roster". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Layout section:

{{result}}

{{txt}}

Vue section:

Let vm = new Vue ({el:'#app', data: {list: ["Primary one", "Li er", "Wang San", "Thursday", "Zhang Wu"], / / random roll call content result:'', / / button text content txt: "roll call" / / flow control switch open:true, / / define timer switch timer:null} Methods: {move () {/ / get a random number of 0-the current array length let random = Math.floor (Math.random () * (this.list.length-0)) / / make the random number the random subscript of the list array Assign value to result, render this.result = this.list [random]} on the page, randomName () {/ / flow control switch if (this.open) {/ / define timer Call the move method this.timer = setInterval (this.move This.txt = "stop roll call" this.open = false} else {/ / clear timer clearInterval (this.timer) this.txt = "start roll call" This.open = true}) "how to use Vue to make a simple random click list" ends here. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report