Default binding inline style with number in object to `px`
See original GitHub issueWhen we want to bind inline style with object, we might use object in data
like this way.
data() {
return {
style: {
width: '400px',
},
};
}
I think it might be useful for users to just write number
and it will suffix with px
automatically.
data() {
return {
style: {
width: 400,
},
};
}
Is it possible to default unit with px
when using numbers?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:4
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Style binding: implicitly assign 'px' as the default unit ... - GitHub
In React, this is the default behavior. It will add 'px' if the unit is not specified. What does the proposed API look...
Read more >How to combine multiple inline style objects? - reactjs
I like to use this to make components with default properties. For example, here's a little stateless component with a default margin-right ...
Read more >Class and Style Bindings - Vue.js
A common need for data binding is manipulating an element's class list and its inline styles. Since they are both attributes, we can...
Read more >inline-size - CSS: Cascading Style Sheets - MDN Web Docs
The inline-size CSS property defines the horizontal or vertical size of an element's block, depending on its writing mode.
Read more >Styling a Vue.js application using CSS - LogRocket Blog
In Vue. js, we can add an inline style to our element by binding the style attribute in the HTML tag. For reference,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@kazupon
Looks good to me though I hope vue will support suffix
px
automatically 😄 Besides, usingfilters
orcomputed
properties might be more flexible for users. Thanks for your reply and great example.@CYBAI I think it’s possible to implement with computed properties. Also, In Vue.js 2.1 later, we can use the filter of
v-bind
.e.g.