This tutorial teaches you how to make a "walking" bootstrap progress bar for your reference. The specific content is as follows
1. Page effect:
Starting position:
After clicking the "Go" button
2 .html code:
<div> <div class="progress progress-striped active"> <div class="progress-bar" role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" v-bind:style="progressStyle">进度条</div> </div> <button type='button' v-on:click='queryEnterprise' class='btn btn-primary'>走</button> </div>
v-bind:style="progressStyle"
Bind inline style:
a. Object syntax: The object syntax of v-bind:style is very intuitive - it looks very like CSS, Actually it is a JavaScript object. CSS property names can be named in camelCase or kebab-case:
eg:
html:
<div v-bind:style="{ color: activeColor, fontSize: fontSize + 'px' }"></div>
js:
data: { activeColor: 'red', fontSize: 30 }
directly bound to a Style objects are usually better and make the template clearer:
html:
<div v-bind:style="styleObject"></div>
js:
data: { styleObject: { color: 'red', fontSize: '13px' } }
b. Array syntax: The array syntax of v-bind:style can combine multiple style objects Applied to an element:
eg:
html:
<div v-bind:style="[styleObjectA, styleObjectB]">
data: { styleObjectA: { color: 'red' }, styleObjectB:{ fontSize: '13px' } }
c. Automatically add prefix: When v-bind:style uses CSS properties that require vendor prefixes, such as transform, Vue.js will automatically Detect and add the appropriate prefix.
3.js code:
<script> export default { components:{}, props:{}, ready:function(){}, computed:{}, methods:{ queryEnterprise:function(){ if(parseInt(this.progressStyle.width)<100){ this.progressStyle.width=parseInt(this.progressStyle.width)+30+'%'; }else{ alert("进度条已经走完"); } } }, data () { return { //进度条样式 progressStyle:{ width:'10%', }, } }, } </script>
4.style
.progress { height: 40px; transition: 3s; } .progress-bar { font-size: 16px; line-height: 40px; }
The above is the entire content of this article, I hope it will be helpful to everyone’s study