admin管理员组文章数量:1366902
The template of my ponent contains this html element:
.grid-item(:style="{ width: columnWidth, backgroundColor: 'blue' }")
and I'd like to set its width value using a puted property:
puted: {
columnWidth () {
return ((this.maxWidth - ( this.marginWidth * 2)) - ((this.columnsCount - 1) * this.gutterWidth)) / this.columnsCount;
}
}
How can I achieve this in a correct manner?
The problem is obviously in the :style="{ width: columnWidth
part
since every thing works perfectly when I set this width:'20px'
for example.
The template of my ponent contains this html element:
.grid-item(:style="{ width: columnWidth, backgroundColor: 'blue' }")
and I'd like to set its width value using a puted property:
puted: {
columnWidth () {
return ((this.maxWidth - ( this.marginWidth * 2)) - ((this.columnsCount - 1) * this.gutterWidth)) / this.columnsCount;
}
}
How can I achieve this in a correct manner?
The problem is obviously in the :style="{ width: columnWidth
part
since every thing works perfectly when I set this width:'20px'
for example.
- 1 You probably need to append some units. – Roy J Commented Jan 5, 2018 at 19:35
- that's very likely! I'm looking up the correct syntax of doing this right now. – Sammi Commented Jan 5, 2018 at 19:41
- Thank you! It was in the official Vue documentation. – Sammi Commented Jan 5, 2018 at 19:45
1 Answer
Reset to default 7I had to append a unit to the columnWidth value in the inline style.
width: columnWidth + 'px'
did the trick.
版权声明:本文标题:javascript - How to pass a computed property as a style property value for a component in Vue.js? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743760173a2534226.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论