I have a Bootstrap Vue ProgressBar. I need to add a pseudo element ::after
with content icon (from FontAwesome) to the element with class .progress-bar
. And I also want it to be dynamic. I have implemented steps in my ProgressBar(from 0 to 100) and I want this icon to go along with ProgressBar line when I click.
<b-progress v-bind:style="styleProgressBar" :value="counter" :max="max"></b-progress>
export default {
components:{
'navbar':navbar
},
name: "myPage",
data() {
return {
counter: 0,
max: 100,
step:1,
}
},
methods:{
prev() {
this.step--;
},
next() {
this.step++;
if (this.counter < 100) {
this.counter += 34;
}
}
}
}
I also saw this: https://v2.vuejs.org/v2/guide/class-and-style.html
<div v-bind:style="styleObject"></div>
data: {
styleObject: {
color: 'red',
fontSize: '13px'
}
}
It seems you'd like to add one icon following the progress bar.
If so, check below demo, it uses one span simulate the icon, then bind left
to move the icon.
Vue.config.productionTip = false
app = new Vue({
el: "#app",
data: {
counter: 0,
max: 100,
intervalID: null
},
methods: {
runTask: function () {
clearInterval(this.intervalID)
this.counter = 0
this.intervalID = setInterval(() => {
this.counter = (this.counter+7)%this.max
}, 1000)
}
}
})
.badge {
background-color:green;
border: 1px solid black;
padding: 2px;
transition: 1s;
}
<script src="https://unpkg.com/vue@2.5.16/dist/vue.js"></script>
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css"/>
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.css"/>
<script src="//unpkg.com/babel-polyfill@latest/dist/polyfill.min.js"></script>
<script src="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.js"></script>
<div id="app">
<button @click="runTask()">Run</button>
<b-progress class="mt-1" :max="max" show-value>
<b-progress-bar :value="counter" variant="success">
<span class="badge" style="position:absolute;" :style="{'left':counter*100/max + '%'}" v-show="counter > 0">x</span>
</b-progress-bar>
</b-progress>
</div>