**
New learning and new journey, let us embark on the new long march of learning vue.js together
Encounter vue.js -------- Awen's vue.js study notes (1)-----First time vue.js
Meet vue.js -------- Awen's vue.js study notes (2-1)-Basic use [1]
Meet vue.js -------- Awen's vue.js study notes (2-2) ----- Basic usage [2]
… … …
Meet vue.js -------- Awen's vue.js study notes (directory)
Pay attention to me, we learn and progress together.
**
Basic usage
We can use the v-model
instructions on the form <input>
, <textarea>
and <select>
create two-way data binding on the element. It will automatically select the correct method to update the element based on the control type. And is responsible for monitoring user input events to update data, and perform some special processing on some extreme scenarios.
1. Text
Simple example: two-way data binding of line text
2. Multi-line text
Simple example:
3. Checkbox
Simple example: check is true, uncheck is equivalent to judge the condition as false
4. Radio buttons
Simple example:
5. Select box
Simple example:
Note:
(1)v-model
The initial values of the value, checked, and selected attributes of all form elements are ignored, and the data of the Vue instance is always used as the data source. So we need a component by JavaScriptdata
declared initial value data.
(2) Interpolation () in the text area<textarea>{ {text}}</textarea>
will not take effect, and v-model should be used instead.
Modifier
1、.lazy
Generally, by default,
v-model
the value of the input box is synchronized with the data after each input event is triggered. But we can add.lazy
modifiers, which change into after the event _ _ then synchronize (you can also be understood as information is no longer with us to change the synchronization input box, but when we complete the input box, lost in the input box After focusing, synchronize the information between the two)
Simple example:
2、.number
We
v-model
added later.number
can be achieved automatically after the value we enter into numeric type
3、.trim
.trim
Used to automatically filter the first and last blank characters we input,
Simple example; in this way, if you tell him to print out on our console, you will find that there are many spaces in front,
but .trim
after joining , it will be automatically filtered out
**
Follow the campus official account, reply to the web front end to receive 50G front-end learning materials for free One, let's learn and make progress together.
**