Getting started with Vue instructions: Let's talk about the six commonly used built-in instructions
青灯夜游
Release: 2022-06-09 20:21:46
forward
2845 people have browsed it
This article will take you through the Vue instructions and introduce the six commonly used built-in instructions in Vue. I hope it will be helpful to everyone!
Instruction classification
Directives are the template syntax provided by vue for developers. The basic structure used to assist developers in rendering pages. (Learning video sharing: vuejs video tutorial)
The data used is defined in the data of the instance, and the event is defined in the methods of the instance Medium
Content rendering instructions: Assist developers to render the text content of DOM elements
Event binding instructions: Assist developers to bind events to elements
Two-way binding instructions: Assist developers to quickly obtain form data without operating the DOM (changes in the data source will be synchronized to the page, and changes on the page will also be synchronized to the data source)
Conditional rendering instructions : Assist developers to control the display and hiding of DOM on demand
List rendering instructions : Assist developers to loop-render a list structure based on an array
1. Content rendering instructions
v-text
can only render plain text content, Will overwrite the original content inside the tag
<p v-text="gender">性别</p>
Copy after login
{{ }} The interpolation expression
can only render plain text content,Will not overwrite The original content inside the tag
<p>性别:{{ gender }}</p>
Copy after login
v-html
can render the tagged string into html content, will overwrite the original content inside the tag
If no parameters are passed: there will be The default formal parameter
event is an object, and the target attribute inside points to the DOM element of the currently bound event
If you pass a parameter: event, it will be overwritten. In order to be usable If the parameter you pass can retain the event, you can manually pass another actual parameter
The above is the detailed content of Getting started with Vue instructions: Let's talk about the six commonly used built-in instructions. For more information, please follow other related articles on the PHP Chinese website!
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn