This article uses Vue to simply implement the changes of the progress bar for your reference. The specific content is as follows First, a wave of effect pictures: Click minus to reduce by 10% each time After the value is reduced to 0%, the minus button is hidden. Then click Restart to restore to the initial state Without further ado, let’s get started with the code <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Home</title> <link rel="stylesheet" href="style.css" > <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="vue-app"> <div class="process"> <div v-bind:style="{width: health+'%'}"></div> </div> <div class="bu"> <button v-on:click="sub" v-show="!eable">Subtract</button> <button v-on:click="reset">Restart</button> </div> </div> js: <script src="app.js"></script> </body> </html> new Vue({ el:"#vue-app", data:{ health: 100, enable : false }, methods : sub : function () { this.health -= 10; if(this.health <= 0){ this.eable = true; } }, reset : function () { this.health = 100; this.eable = false; } } }); CSS: .process{ width: 250px; height: 30px; margin: 0 auto; border: black 4px solid; } .process div{ height: 30px; background: red; } .bu{ width: 250px; margin: 20px auto; } .bu button{ margin: 0 20px; } The simple implementation idea is as follows: Use v-bind:style to bind the value of width to health. When decreasing, decrease by 10 each time. When it decreases to 0, hide the decrease button. When hiding, you can use a state variable to control it according to v-show. When it is true, it will be displayed, and when it is false, it will be hidden. 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:
|
<<: Detailed explanation of MySQL startup options and system variables examples
>>: Teach you how to build a Hadoop 3.x pseudo cluster on Tencent Cloud
Table of contents 1. React.FC<> 2. class xx...
This article example shares the specific code of ...
1. Set the parent container to a table and the ch...
【question】 When the outer table and the inner tab...
1. CDN It is the most commonly used acceleration ...
0. When I made this document, it was around Decem...
As more and more developers use SASS, we need to ...
Table of contents Preface: 1.Brief introduction t...
At the beginning, I felt sad. The screenshots are...
1. Installation of MYSQL 1. Open the downloaded M...
Table of contents 1. Front-end control 1. In the ...
Preface In database operations, in order to effec...
ERROR 1290 (HY000) : The MySQL server is running ...
question After the company migrated the server, t...
MySQL executes SQL through the process of SQL par...