Skip to content

Instantly share code, notes, and snippets.

@fraaalk
Last active October 30, 2017 13:46
Show Gist options
  • Select an option

  • Save fraaalk/e6ecef5d8c40f919407cf537fd386497 to your computer and use it in GitHub Desktop.

Select an option

Save fraaalk/e6ecef5d8c40f919407cf537fd386497 to your computer and use it in GitHub Desktop.
<template>
<article
:style="{ height }">
<button @click="changeHeight">
</button>
</article>
</template>
<script>
export default {
data() {
return {
height: 'auto',
};
},
methods: {
changeHeight() {
this.height = 'auto';
.... something gets changed, template gets updated ... height should have changed
},
setHeight() {
this.height = `${this.$el.clientHeight}px`;
}
},
updated() {
if (this.height === 'auto') {
this.setHeight();
}
},
mounted() {
this.height = this.setHeight();
},
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment