当前位置:网站首页>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>
边栏推荐
- What is Wi Fi 6 (802.11ax)? Why is Wi Fi 6 important?
- Xiaosha's counting (bit operation, Combinatorial Mathematics) - Niuke
- Chapter VII (structure)
- Google Earth engine (GEE) 01- the prompt shortcut ctrl+space cannot be used
- B站增量数据湖探索与实践
- Informatics Orsay all in one 1354: bracket matching test
- Chapter 5 (array)
- 1010. song backtracking with total duration divisible by 60
- Pycharm settings
- Google Earth Engine(GEE) 02-基本了解和学习资源
猜你喜欢

Win11 open folder Caton solution summary

Opencv mouse event + interface interaction drawing rectangle polygon selection ROI

The 9th zero code training camp is officially open for registration! (Beijing, Shanghai, Guangzhou and Shenzhen)

Important reference indicators for data center disaster recovery: RTO and RPO

Uniapp uses uviewui

Opencv鼠标事件+界面交互之绘制矩形多边形选取感兴趣区域ROI
![Jemter stress test - visualization tool - [usage]](/img/b1/3c367b690bbc16ae5a3e9e2c85af73.png)
Jemter stress test - visualization tool - [usage]

Median segmentation (find rules) - Niuke

The first screen time, you said you optimized it, then you calculated it and showed it to me!

Chapter 3 (data types and expressions)
随机推荐
信息学奥赛一本通 1355:字符串匹配问题(strs)
Basic use of swiperefreshlayout, local refresh of flutterprovider
有序排列
The first screen time, you said you optimized it, then you calculated it and showed it to me!
What are the characteristics of digital factory in construction industry
This article will take you to learn in detail what is FTTH
Blue Bridge Cup 3 sequence summation
Webrtc has become the official standard of W3C and IETF, and mobile terminal development
Record the dependent installation problems encountered in building the web assets when developing pgadmin
2021 project improvement
Go language custom DNS resolver practice yyds dry inventory
45. jumping game II dynamic planning DP
Uniapp wechat withdrawal (packaged as app)
Install the local Google plug-in and watch the free video through the oil monkey script
Class class of box selection four to and polygon box selection based on leaflet encapsulation
Open a file at line with'filename:line'syntax - open a file at line with'filename:line' syntax
Pic 10B parsing
2: String insert
CMDA 3634 image processing
Deeply analyze storage costs and find cost reduction solutions