Vue.js's inline expressions are very convenient, but for more complicated logic, you should use computed properties. Practically, computed properties are variables which their value depends on other factors.
Computed properties work like functions that you can use as properties. But there is a significant difference. Every time a dependency of a computed property changes, the value of the computed property re-evaluates.
In Vue.js, you define computed properties within the computed
object inside your Vue
instance:
<html> <head> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"> <title>Hello Vue</title> </head> <body> <div class="container"> a={{ a }}, b={{ b }} <pre> {{$data | json}} </pre> </div> </body> <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26...