Example p303

This example demonstrates that, in addition to the name of a data property, the directive to bind attribute :attr can also evaluate simple JavaScript expression. However, a computed property is more appropriate for more complicated logic. A computed property is similar to a read-only data property, and its value is usually calculated from the data properties.

The style attribute of HTML elements allows you to use CSS style rules to change the appearance of the elements. In Vue, you can bind a JavaScript object (group of property names and values) to the style attribute. Vue will handle the difference in naming convention in JavaScript (camelCase) and CSS (kebab-case).

There is also a special handling in binding the class attribute. See online reference for more information.


Temperature: {{ temperature }}°C
Rain: {{ rain }}%

Try the following

Icons made by Vitaly Gorbachev from www.flaticon.com
Icons made by Freepik from www.flaticon.com
Icons made by bqlqn from www.flaticon.com