Reputation: 53
I am trying to use the card component in bootstrap-vue. I want to get the height of the card after it is rendered since the height changes based on the amount of text in it. What would be a solution?
Upvotes: 0
Views: 304
Reputation: 49919
You can do a watch
on your model.
watch : {
'modelThatChanges'() {
var height = document.getElementById("idOfCard").offsetHeight; // includes border and padding
console.log(height)
}
}
If this gives an issue that it presents the last value and not the new height. You have to do a Vue.nextTick
and it will look like:
watch : {
'modelThatChanges'() {
Vue.nextTick(() => {
var height = document.getElementById("idOfCard").offsetHeight; // includes border and padding
console.log(height)
});
}
}
Upvotes: 3