A brief discussion on VUE uni-app template syntax

A brief discussion on VUE uni-app template syntax

1.v-bind (abbreviation:)

To use data variables defined in data in component properties, or to use expressions in component properties, you need to specify them with v-bind.

Abbreviation:

2. v-on (abbreviated as @)

Listening to DOM events

click.stop can prevent events from penetrating

3.v-model

Two-way data binding

4. v-if, v-else-if, v-else

Conditional judgment to determine whether a certain content is mounted

5.v-show

Conditional judgment to determine whether a certain content is displayed

6. Ternary Operator

7. Empty tag block

8. v-for: List rendering

<template>
	<view v-bind:class="msg" v-bind:data="1+2">
		{{msg}} world!-{{num}}
		<button v-on:click="show">Click me</button>
		<input v-model="msg" />
		<view v-if="flag">vue</view>
		<view v-else>H5</view>
		<view>{{flag ? 'Show':'Hide'}}</view>
		<block>
			<text>block empty tag</text>
		</block>

		<view v-for="(item, index) in arr">{{index+1}}:{{item}}</view>
		<view @click="c1">
			Parent <view @click.stop="c2">Child</view>
		</view>
	</view>
	
</template>
<script>
export default{
	//Initialize data,
	//data:{}, using object form data will not change, not recommended data(){
		return {
			msg:'hello',//variable arr:['vue','H5','CSS'],//array flag:true,//Boolean value num: 1
		}
	},
	onLoad(){
		setTimeout(()=>{
			this.num++;
		},2000)
	},
	methods:{
		show(){
			console.log('clicked');
			this.flag=!this.flag;
		},
		c1(){
			console.log('I am the parent');
		},
		c2(){
			console.log('I am a child');
		}
	}
}
</script>

Summarize

This article ends here. I hope it can be helpful to you. I also hope you can pay more attention to more content on 123WORDPRESS.COM!

You may also be interested in:
  • How to create a template project using vue-cli
  • In-depth understanding of Vue3 template compilation principle
  • How to set vue template content in vscode
  • Implementation of Vue template in VsCode
  • Detailed explanation of several methods of dynamically adding templates in Vue
  • A brief talk about various data bindings of Vue templates
  • Detailed explanation of VUE custom component template method
  • Vue template syntax - detailed explanation of interpolation
  • Simple vue-resourse gets json and applies it to the template example
  • Detailed explanation of Vue front-end information details page template

<<:  MySQL data types full analysis

>>:  Docker installation rocketMQ tutorial (most detailed)

Recommend

Guide to using env in vue cli

Table of contents Preface Introduction-Official E...

Install Apache2.4+PHP7.0+MySQL5.7.16 on macOS Sierra

Although Mac systems come with PHP and Apache, so...

MySQL 5.7.23 decompression version installation tutorial with pictures and text

It is too troublesome to find the installation tu...

jQuery implements percentage scoring progress bar

This article shares the specific code of jquery t...

How to query whether the mysql table is locked

Specific method: (Recommended tutorial: MySQL dat...

The process of installing SVN on Ubuntu 16.04.5LTS

This article briefly introduces the process of se...

JS realizes the effect of picture waterfall flow

This article shares the specific code of JS to re...

How to modify the root user password in mysql 8.0.16 winx64 and Linux

Please handle basic operations such as connecting...

HTML Basics Must-Read - Comprehensive Understanding of CSS Style Sheets

CSS (Cascading Style Sheet) is used to beautify H...

mysqldump parameters you may not know

In the previous article, it was mentioned that th...

Detailed explanation of persistent storage of redis under docker

In this chapter, we will start to operate redis i...

Super detailed basic JavaScript syntax rules

Table of contents 01 JavaScript (abbreviated as: ...

Add crontab scheduled tasks to debian docker container

Now most of the Docker images are based on Debian...

Vue realizes the whole process of slider drag verification function

Rendering Define the skeleton, write HTML and CSS...