当前位置:网站首页>Wechat applet development two or three things
Wechat applet development two or three things
2022-07-16 06:16:00 【BeforeEasy】
How to add background photos
index Upload the background picture under the page folder
wxml in
<image src='./bg1.jpg'></image>
wxss in
image{
position: absolute;
width: 100%;
/* height: 50%; */
display:flex;
height: 100%;
justify-content: center;
align-items:center;
}
Used in other components z_index To show the level
How to read DATA Data in
stay index.js Next Page Are there in data data , Want to get the value of the read variable in other functions :
(data There are array variables in text_list)
var that = this;
var length = that.data.text_list.length;
How to give DATA assignment
After requesting content from the database , You want to assign to data The variables in the :
var that = this;
that.setData({
text_list : old_data.concat(new_data)
})
How to center text 、 Word wrap
wxml in
Note that if text Wrap the , Then it will also show a line break
<view class="usermotto" >
<text class="user-motto" user-select="true">“{
{motto}}”</text>
</view>
wxss in
.user-motto {
text-overflow:ellipsis;
flex-wrap:wrap;
line-height:25px;
font-weight: 800;
/* border: 3rpx solid #6e11ac; */
}
.usermotto {
word-break: break-all;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
flex-wrap:wrap;
z-index: 1;
}
How to generate random numbers
//0-9
var random = Math.floor(Math.random() * 10);
How to display the contents of an array at the front end
<block wx:for="{
{arr}}">
<view >{
{index}}:{
{item.text}}</view>
</block>
button Click events for
button Binding function in , Such as :
bindtap="handleTap"
And then in js To realize handleTap function
How to use applet cloud
It must be the official registration number , The test number doesn't seem to work 
In the code :
wx.cloud.init({
env: 'env_id'
})
const db = wx.cloud.database({
});
How to break through the applet cloud to query at most 20 Restrictions on
Search many times , Splice into the result
var that = this
var MAX_LIMIT = 20
db.collection('db_name').count().then(async res =>{
let total = res.total;
// The calculation needs to be divided into several times
const batchTimes = Math.ceil(total / MAX_LIMIT)
console.log("batchTimes:",batchTimes)
// Carrying all read operations promise Array of
for (let i = 0; i < batchTimes; i++) {
await daily5.skip(i * MAX_LIMIT).limit(MAX_LIMIT).get().then(async res => {
let new_data = res.data
let old_data = that.data.text_list
// console.log("newdata",new_data)
that.setData({
text_list : old_data.concat(new_data)
})
})
}
})
边栏推荐
- 最详细的window10虚拟机安装,手把手安装虚拟机,解决家庭版window找不到Hyper-V选项
- Infrastructure nftscan officially released Solana network NFT browser
- Analysis of error monitoring principle
- 【论文笔记】—毫米波雷达穿雾式高分辨率成像—Supervised—HawkEye系统—2020-CVPR
- 机器学习整理(几种学习方式的介绍)
- 一步一步来制作3D导航栏
- 一个简单的英文自然语言处理流程
- 消息转发机制--拯救你的程序崩溃
- SQL must know and be able Series 1 Basic retrieval related
- Math object in JS
猜你喜欢

unity实验-模拟太阳系星体运动

How did the situation that NFT trading market mainly uses eth standard for trading come into being?

Notes 2 of network communication security

Dense Contrastive Learning for Self-Supervised Visual Pre-Training(基于密集对比学习的自我监督视觉预训练)2021

目标检测(1)——数据预处理和数据集的切分

Unity experiment - control the movement of game objects

chrome浏览器91版本SameSite by default cookies被移除后的解决方案,Chrome中跨域POST请求无法携带Cookie的解决方案

How to solve the "Impossible Triangle" problem of data flow?

Nftscan Developer Platform launches Multi Chain NFT data pro API service

【ARXIV2204】Vision Transformers for Single Image Dehazing
随机推荐
MSF infiltrates Win2003 with eternal blue
【NeurIPS】ViTAE: Vision Transformer Advanced by Exploring Intrinsic Inductive Bias
Object member detection
微服务架构九大特性
《代码整洁之道》读后笔记
Notes 1 of network communication security
【ARXIV2204】Simple Baselines for Image Restoration
Compilation principle - lexical analyzer design
Practice of recording, uploading and playing audio wechat applet
【MIT Missing Semester 2】Shell Tools
HTTP 缓存机制详解
扶朕起来,朕还能接着编!
explain使用方法及结果分析
Detailed explanation of HTTP caching mechanism
Graphic and image programming practice course report
将String转为Date,方便快捷
Moss privacy computing all-in-one machine has passed 83 evaluations of Shenzhen Guojin evaluation center
unity实验-重力撞墙
【MIT Missing Semester 2】Shell Tools
Built in function of JS array