In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to achieve gradient progress bar in Vue". In daily operation, I believe many people have doubts about how to achieve gradient progress bar in Vue. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts of "how to achieve gradient progress bar in Vue". Next, please follow the editor to study!
Functional requirements
The total grid number of the progress bar can be customized.
The proportion of the current number of pieces corresponds to the current number of blue squares
The blue gradient of the lattice should conform to the UI design.
First determine the value in props, that is, the value that the component needs to receive.
There are only names, totals, and current values
Props: {name: {type:String, default: () = > ('data name')}, total: {type:Number, default: () = > (24)}, value: {type:Number, default: () = > (18)},}
Then there is the main implementation method, where a cubeCount is received as a parameter, that is, the total grid number needs to be defined.
Methods: {initStatus (cubeCount) {/ / 1. Get the width of the total grid number div let totalDomWidth=this.$refs.total.offsetWidth; / / 2. Calculate the ratio of the current grid let ratio= (this.value/this.total); / / 3. Calculate the width of each lattice let cubeWidth=Math.floor ((totalDomWidth/cubeCount)-1);},}
When calculating the width of each grid, Math.floor is used to round down. As for the following-1, it is the spacing between the grids.
Then, according to the width of each grid and the number of grids, the total lattice is dynamically generated and inserted into the div.
For (let ionome0), data () {return {};}, mounted () {let that=this this.initStatus (16);}, updated () {this.initStatus (16);}, methods: {initStatus (cubeCount) {let that=this; let totalDomWidth=this.$refs.total.offsetWidth Let ratio= (this.value/this.total); let cubeWidth=Math.floor ((totalDomWidth/cubeCount)-1); let cubeDomArr; for (let iTuno)
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.