Vue API
- Vue API uses the declarative programming approach
- It uses
data
(initial state), methods
(change state), and computed
(show state)
new Vue({
el: '#app'
data: {
textInput: ''
}
methods: {
onInput: function (event) {
this.textInput = event.target.value; /* this refers to the state object */
}
}
computed: {
identicon: function() {
return jdenticon.toSvc(this.textInput, 200);
}
}
});
Declarative Programming
- In a
declarative programming
, a initial state
and a set of rules
are used to accomplish a goal
- The
imperative programming
in contrast is just a set of instructions to be followed in order