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

C# implements MySQL command line backup and recovery

There are many tools available for backing up MyS...

Implementation of effective user groups and initial user groups in Linux

First check the /etc/group file: [root@localhost ...

Practical notes on installing Jenkins with docker-compose

Create a Directory cd /usr/local/docker/ mkdir je...

Limiting the number of short-term accesses to a certain IP based on Nginx

How to set a limit on the number of visits to a c...

Nginx stream configuration proxy (Nginx TCP/UDP load balancing)

Prelude We all know that nginx is an excellent re...

Detailed examples of replace and replace into in MySQL into_Mysql

MySQL replace and replace into are both frequentl...

Vue+Element UI realizes the encapsulation of drop-down menu

This article example shares the specific code of ...

MySQL 8.0.18 installation and configuration method graphic tutorial under MacOS

This article records the installation of MySQL 8....

Detailed explanation of MySQL 8.0.18 commands

Open the folder C:\web\mysql-8.0.11 that you just...

HTML head tag detailed introduction

There are many tags and elements in the HTML head ...

The iframe refresh method is more convenient

How to refresh iframe 1. To refresh, you can use j...

React new version life cycle hook function and usage detailed explanation

Compared with the old life cycle Three hooks are ...

CSS hacks \9 and \0 may not work for hacking IE11\IE9\IE8

Every time I design a web page or a form, I am tr...