当前位置:网站首页>Record the creation process of a joke widget (II)
Record the creation process of a joke widget (II)
2022-06-24 03:28:00 【leo689】
Record the whole process of creating a joke widget ( Two )
The joke widget is really good - A sneak peek
Welcome to scan the yard and watch , Welcome to sesame joke applet ! thank you !
home page
The home page contains functions :
- Display content list
- Click for details
- give the thumbs-up
- Click on the upper right corner to share the entire applet
- Share individual content
Display content list
Technical point :
- v-for Cyclic instruction
- uni-card Card components
Technical realization
introduce uni-card Card components
<view class="example-body">
<uni-card :isShadow="true" :title=item.title mode="title" thumbnail="/static/zhimaxiaohua.png" note="true"
@click="">
<view>
<view class="content-box">
<text class="content-box-text"> Card content </text>
</view>
</view>
<template v-slot:footer>
<view class="footer-box">
<view class="applause" @click="footerClick(' like ')">
<text> like </text>
</view>
</view>
</template>
</uni-card>
</view>introduce v-for Cyclic instruction
<view v-for="(item,index) in dataList"> </view>
Sample data display
<template>
<view>
<view v-for="(item,index) in dataList">
<view class="example-body">
<uni-card :isShadow="true" :title=item.title mode="title" thumbnail="/static/zhimaxiaohua.png"
note="true" @click="">
<view>
<view class="content-box">
<text class="content-box-text">{{item.content}}</text>
</view>
</view>
<template v-slot:footer>
<view class="footer-box">
<view class="applause" @click="footerClick(' like ')">
<text> like </text>
</view>
</view>
</template>
</uni-card>
</view>
</view>
</view>
</template>
<script>
import indexJokeJsonData from "@/mockdata/index-jokes.json"
export default {
data() {
return {
dataList: indexJokeJsonData
}
}
}
</script>Mock Of json data
index-jokes.json
[
{
"id": 1,
"title": " Sesame joke ",
"content": " This is the content "
},
{
"id": 2,
"title": " Sesame joke ",
"content": " This is the content "
},
{
"id": 3,
"title": " Sesame joke ",
"content": " This is the content "
}
]Click for details
Click to view details , It will jump to the details page , Jump will carry relevant parameters , such as id.
Click event function :@click="viewDetail(index)"
methods: {
viewDetail: function(index) {
uni.navigateTo({
url: '/pages/joke-detail/joke-detail?index=' + index + '&dataSource=indexJokes'
})
}
}Detail page receiving function , You need to create a joke-detai.vue file
<template>
<view>
<view class="content-box">
<view class="head">
<text>{{list[index].title}}</text>
</view>
<text class="content-box-text">
{{list[index].content}}
</text>
</view>
</view>
</template>
<script>
import indexJokeJsonData from "@/mockdata/index-jokes.json"
export default {
data() {
return {
list: indexJokeJsonData,
index: 0
}
},
onLoad: function(option) {
this.index = option.index;
var dataSourceParam = option.dataSource;
if(dataSourceParam==='indexJokes') {
this.list=indexJokeJsonData
}
}
}
</script>give the thumbs-up
footerClick(types) {
uni.showToast({
title: types,
icon: 'none'
})
}Click on the upper right corner to share the entire applet
Share individual content
These two parts will be put into a special account about the sharing function of wechat applet
Style rollup
index.vue Home page style
<style lang="scss">
.example-body {
/* #ifndef APP-NVUE */
display: block;
/* #endif */
padding: 1px 0;
}
.example-box {
margin: 12px 0;
}
.image-box {
/* #ifndef APP-NVUE */
display: flex;
flex-direction: column;
/* #endif */
height: 350rpx;
overflow: hidden;
}
.image {
/* #ifndef APP-NVUE */
width: 100%;
height: 100%;
/* #endif */
flex: 1;
}
.content-box {
padding-top: 20rpx;
}
.content-box-text {
font-size: 14px;
line-height: 22px;
}
.footer-box {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
justify-content: space-between;
flex-direction: row;
}
.footer-box__item {
align-items: center;
padding: 1px 0;
font-size: 12px;
color: #666;
}
.applause image {
width: 60rpx;
height: 60rpx;
}
button::after {
border: none;
}
.applause button {
background-color: #FFFFFF;
}
</style>Record the whole process of creating a joke widget ( One )
边栏推荐
- What are the security guarantees for cloud desktop servers? What are the cloud desktop server platforms?
- Micro build low code enterprise exchange day · Shenzhen station opens registration
- How to apply for trademark registration? What are the steps?
- If the cloud knows that security is important
- What is edge computing? What are the characteristics of the Internet platform edge calculator?
- What are the responsibilities of cloud desktop administrators? How to use cloud desktop?
- Use Charles to capture the package of the applet through the mobile agent
- How is intelligent character recognition realized? Is the rate of intelligent character recognition high?
- Sorting out of key vulnerabilities identified by CMS in the peripheral management of red team (I)
- LeetCode 1047. Delete all adjacent duplicates in the string
猜你喜欢

Simple and beautiful weather code

On Sunday, I rolled up the uni app "uview excellent UI framework"
![[summary of interview questions] zj5](/img/d8/ece82f8b2479adb948ba706f6f5039.jpg)
[summary of interview questions] zj5

QT creator tips

Ar 3D map technology

Community pycharm installation visual database

Sorting out of key vulnerabilities identified by CMS in the peripheral management of red team (I)

Get to know MySQL database
![[summary of interview questions] zj6 redis](/img/4b/eadf66ca8d834f049f3546d348fa32.jpg)
[summary of interview questions] zj6 redis
随机推荐
What is the edge calculator force? What about the edge calculator?
How to build a shopping website? What problems should be paid attention to in the construction of shopping websites?
What are the configuration requirements for cloud desktop servers? What are the main characteristics of the three points?
Grpc: how to reasonably manage log configuration?
Grpc: how do I start multiple ports?
ClickHouse Buffer
Big coffee face to face | Dr. Chen Guoguo talks about intelligent voice
What is the GPU usage for cloud desktops and servers? What can cloud desktop do?
How is intelligent character recognition realized? Is the rate of intelligent character recognition high?
What is an edge calculator? How is the unit price of the edge calculator calculated?
How do I check the trademark registration number? Where do I need to check?
Grp: how to add Prometheus monitoring in GRP service?
Get to know MySQL database
How to register a trademark? What needs to be prepared?
golang with script
How to set up a cloud desktop server? Is there a charge for cloud desktop server setup?
Which domestic cloud desktop server is good? What are the security guarantees for cloud desktop servers?
Use Charles to capture the package of the applet through the mobile agent
Grpc: how to make grpc provide swagger UI?
"Sharp weapon" for enterprise resumption? When the sale comes, the contract should be signed like this!