A JavaScript framework that lets you build web UIs, its core concepts are:
Lifecycle methods are called outside the "methods" object.
<template> <div id="app"> <input name="name" v-model="name" /> {{name}} </div> </template> <script> export default { name: "App", data: function () { return { name: "", }; }, methods: { handleName: function (event) { this.name = event.target.value; }, } }; </script> <style> #app { color: #2c3e50; } </style>
<template> <div id="app"> <input name="name" v-model="name" /> {{name}} </div> </template> <script> export default { name: "App", data: function () { return { name: "", }; }, methods: { handleName: function (event) { this.name = event.target.value; }, } }; </script> <style> #app { color: #2c3e50; } </style>
v-show | show an element if certain condition is met but it’s still in the DOM |
v-bind | binds one or more attributes to a DOM element or a component prop to an element |
v-on | Lets you listen to DOM events to run some JavaScript when the events are triggered |
v-model | Used for binding with form inputs |
v-if / v-if-else / v-else | Same thing as v-show except it removes it from the DOM |
v-for | Iterate through Arrays and Objects |
v-once | Renders the element once and will never change |
<script> export default { name: "App", data: function () { return { name: "", }; }, methods: { handleName: function (event) { this.name = event.target.value; }, } }; </script>
<script> export default { name: "App", data: function () { return { name: "", }; }, methods: { handleName: function (event) { this.name = event.target.value; }, } }; </script>
You can access any state within these methods using the “this” keyword
<script> export default { name: "App", data: function () { return { name: "", }; }, created: function (event) { this.name = "created"; }, methods: { handleName: function (event) { this.name = event.target.value; }, } }; </script>
<script> export default { name: "App", data: function () { return { name: "", }; }, created: function (event) { this.name = "created"; }, methods: { handleName: function (event) { this.name = event.target.value; }, } }; </script>