当前位置:网站首页>Introduction to uni app grammar
Introduction to uni app grammar
2022-06-26 07:58:00 【Small slag bright】
Catalog
uni-app Introduction to grammar
Attribute binding and interpolation expression
v-bind:class || :class
- Binding of properties
<view :class="title" >
{
{ title }} <br />
<text v-bind:class="title2">{
{title2}}</text>
</view>
Event binding
- @click=“btn1” Event binding abbreviation
<button type="default" @click="btn1"> Button 1</button>
<button type="default" v-on:click="btn2"> Button 2</button>
Event modifier
- .stop Stop bubbling
- That is, the child event will trigger the parent event due to the bubbling event , Use .stop To stop
<template>
<view>
I am a about
<view class="" @click="c1">
I'm the father
<view @click.stop="c2"> I am son </view>
</view>
</view>
</template>
<script>
export default {
data() {
},
methods: {
c1() {
console.log('c1');
},
c2() {
console.log('c2');
}
}
}
</script>
<style>
</style>
Two-way binding of data
- Two way binding of data depends on form modification
<input type="text" v-model="title2" />
export default {
data() {
return {
title:" I'm a chicken dish ",
title2:"t2"
}
},
}
Conditional judgment and three eyes
- Three items and v-if
<template>
<view class="content">
<view :class="title" >
<button type="default" v-on:click="btn2"> Button 2</button>
<view v-if="flag">
{
{
flag }}
</view>
<view v-else>
{
{
flag }}
</view>
<view :class="flag? 'red' : 'pink'">
{
{
flag }}
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
flag:true
}
},
onLoad() {
},
methods: {
btn2(){
console.log("btn2")
this.flag = !this.flag
},
}
}
</script>
<style>
.red{
color: red;
}
.pink{
color: pink;
}
</style>
- v-if And v-else-if And v-else and v-show
<template>
<view class="content">
<view :class="title">
<button type="default" @click="btn1"> Button 1</button>
<button type="default" v-on:click="btn2"> Button 2</button>
<view v-show="flag">
I am a show
</view>
<view v-if="num == 1">{
{
num}}</view>
<view v-else-if="num == 2">{
{
num}}</view>
<view v-else>{
{
num}}</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title2: "t2",
flag: true,
num:1
}
},
onLoad() {
},
methods: {
btn1() {
this.num = 6
},
btn2() {
this.flag = !this.flag
this.num = 2
},
}
}
</script>
<style>
.red {
color: red;
}
.pink {
color: pink;
}
</style>
The list of rendering
- Use v-for Instructions
<template>
<view class="wrap">
<view v-for="(item,index) in list" :key="index">
<view>
{
{
item.age }} -- {
{
index }}
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
list:[
{
age:20,
},
{
age:30,
},
{
age:40,
},
]
}
}
}
</script>
边栏推荐
- Quickly upload data sets and other files to Google colab ------ solve the problem of slow uploading colab files
- The first multi platform webcast of 2021ccf award ceremony pays tribute to the winners! CCF outstanding engineer
- Use middleware to record slow laravel requests
- [UVM basics] understanding of sequence and sequencer
- Real machine debugging of uniapp custom base
- PCB miscellaneous mail
- Chapter II (summary)
- 项目管理学习
- Jemter stress test - basic requirements - [teaching]
- 1010. song backtracking with total duration divisible by 60
猜你喜欢

Attention mechanism yyds, AI editor finally bid farewell to P and destroyed the whole picture

Redis (4) -- Talking about integer set

Apache InLong毕业成为顶级项目,具备百万亿级数据流处理能力!

Chapter 9 (using classes and objects)

PCB miscellaneous mail

Solve psycopg2 NotSupportedError: PQconninfo not available in libpq < 9.3

Median segmentation (find rules) - Niuke

Niuniu looks at the cloud (greedy, hash, push formula) - the first session of Niuke winter vacation training camp

Junit

ASP. Net and Net framework and C #
随机推荐
Two models of OSPF planning: double tower Raider and dog tooth crisscross
Detailed explanation of the generate go file command of import in golang (absolute detail)
How to design API return codes (error codes)?
[UVM practice] Chapter 3: UVM Fundamentals (3) field automation mechanism
Bluebridge cup 1 introduction training Fibonacci series
ECE 9203/9023 analysis
Xiaosha's counting (bit operation, Combinatorial Mathematics) - Niuke
Opencv mouse event + interface interaction drawing rectangle polygon selection ROI
Jemter 壓力測試 -基礎請求-【教學篇】
I want to create SQL data (storage structure)
Redis (4) -- Talking about integer set
ASP. Net and Net framework and C #
B站增量数据湖探索与实践
PyTorch-12 GAN、WGAN
Color code
[UVM basics] connect of UVM_ Phase execution sequence
Listview control
Tsinghua Yaoban chendanqi won Sloan award! He is a classmate with last year's winner Ma Tengyu. His doctoral thesis is one of the hottest in the past decade
Understanding of closures
指南针炒股软件开户是合法的吗?安全吗