Example p302

In this example, we create a Vue component vm to show weather information. Two data properties of the component object, temperature and rain are displayed in the HTML template using the mustache notation {{ property }}. An important feature of Vue is reactivity. When a property in data changes, Vue will update the HTML content generated from the properties.

We can also bind an HTML attribute (e.g. src of <img>) using the Vue directive v-bind:attr. In this example, we write v-bind:src="conditionURL" or :src="conditionURL" to bind the image URL attribute src to the data property conditionURL. If the property changes, Vue will automatically update the HTML attribute.


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