当前位置:网站首页>For instruction, uploading pictures and display effect optimization of simple wechat applet development
For instruction, uploading pictures and display effect optimization of simple wechat applet development
2022-07-03 03:34:00 【Water W】
This is a continuation of the previous one Simple version of Page Jump of wechat applet development 、 Data binding 、 Get user information 、 Get user location information
https://blog.csdn.net/qq_45956730/article/details/125252305?csdn_share_tail=%7B%22type%22%3A%22blog%22%2C%22rType%22%3A%22article%22%2C%22rId%22%3A%22125252305%22%2C%22source%22%3A%22qq_45956730%22%7D&ctrtid=UdFQC
Catalog
6、 ... and 、 To upload pictures
Display effect optimization 1:
Display effect optimization 2:
5、 ... and 、for Instructions
To write goods page
(1)wxml
The interior is equivalent to helping us make a “for item in dataList” loop
<!--pages/goods/goods.wxml-->
<text> List of goods </text>
<view>
<view wx:for="{
{ dataList }}">{
{index}}-{
{item}}</view>
</view>
<view>
<view wx:for="{
{ UserInfo }}">{
{index}}-{
{item}}</view>
</view>
or
<!--pages/goods/goods.wxml-->
<text> List of goods </text>
<view>
<view wx:for="{
{ dataList }}" wx:for-index="idx" wx:for-item="x">{
{idx}}-{
{x}}</view>
</view>
<view>
<view wx:for="{
{ UserInfo }}" wx:for-index="idx" wx:for-item="x">{
{idx}}-{
{x}}</view>
</view>(2)js
// pages/goods/goods.js
Page({
/**
* Initial data of the page
*/
data: {
dataList: [" Input "," Buddha's birthday "," Birthday song "],
UserInfo: {
name:"alex",
age: 18,
gender: false
}
},
/**
* Life cycle function -- Monitor page loading
*/
onLoad(options) {
},
/**
* Life cycle function -- Listening page first rendering completed
*/
onReady() {
},
/**
* Life cycle function -- Monitor page display
*/
onShow() {
},
/**
* Life cycle function -- Monitor page hidden
*/
onHide() {
},
/**
* Life cycle function -- Monitor page uninstall
*/
onUnload() {
},
/**
* Page related event handler -- Monitor user pull-down action
*/
onPullDownRefresh() {
},
/**
* Handling function of page pull bottom event
*/
onReachBottom() {
},
/**
* Users click the upper right corner to share
*/
onShareAppMessage() {
}
})Show the effect :

6、 ... and 、 To upload pictures
To write home page :
(1)wxml
<!--pages/home/home.wxml-->
<view class="menu">
<view class="item">
<image src="/static/link-01.png"></image>
<text> The high-quality goods </text>
</view>
<view class="item">
<image src="/static/link-01.png"></image>
<text> The high-quality goods </text>
</view>
<view class="item">
<image src="/static/link-01.png"></image>
<text> The high-quality goods </text>
</view>
<view class="item">
<image src="/static/link-01.png"></image>
<text> The high-quality goods </text>
</view>
</view>
<navigator url="/pages/list/list?id=566"> Jump to the page </navigator>
<view bindtap="uploadImage"> Please upload the picture :</view>
<view class="images">
<image wx:for="{
{images}}" src="{
{item}}"></image>
</view>(2)js
// pages/home/home.js
Page({
/**
* Initial data of the page
*/
data: {
images: ["/images/link-01.png","/images/link-02.png","/images/ Default Avatar .jpeg"]
},
uploadImage() {
wx.chooseImage({
count: 9,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success:function(res) {
console.log(res)
}
})
},
/**
* Life cycle function -- Monitor page loading
*/
onLoad(options) {
},
/**
* Life cycle function -- Listening page first rendering completed
*/
onReady() {
},
/**
* Life cycle function -- Monitor page display
*/
onShow() {
},
/**
* Life cycle function -- Monitor page hidden
*/
onHide() {
},
/**
* Life cycle function -- Monitor page uninstall
*/
onUnload() {
},
/**
* Page related event handler -- Monitor user pull-down action
*/
onPullDownRefresh() {
},
/**
* Handling function of page pull bottom event
*/
onReachBottom() {
},
/**
* Users click the upper right corner to share
*/
onShareAppMessage() {
}
})(3)wxss
/* pages/home/home.wxss */
image {
width: 100rpx;
height: 100rpx;
border-radius: 50rpx;
}
.menu {
display: flex;
/* Arrange horizontally , Specify the spindle direction */
flex-direction: row;
/* How elements are displayed horizontally , Specify how to display in the spindle direction :center */
justify-content: space-around;
}
.menu .item {
display: flex;
flex-direction: column;
align-items: center;
}
.images {
width: 200rpx;
height: 200rpx;
padding: 5rpx;
}
Show the effect :
(1) Click on “ Please choose a picture ” after , A selection page will pop up ,

(2) On the pop-up selection page , After selecting the picture ,console The selected picture information will be printed in .

Display effect optimization 1:
(3) here , We modify uploadImage() function , In order to upload and display the pictures we choose on the page ,
data: {
images: ["/images/link-01.png","/images/link-02.png","/images/ Default Avatar .jpeg"]
},
uploadImage() {
var that = this
wx.chooseImage({
count: 9,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success:function(res) {
console.log(res)
that.setData({images: res.tempFilePaths})
}
})
},(4) recompile , Click on “ Please choose a picture ” after , Select a picture on the pop-up selection page ,

Click on “ open ” after , The display effect of the page is ,

Display effect optimization 2:
(3) here , We modify uploadImage() function , In order to make the pictures we choose can be uploaded and displayed on the page existing After the picture of ,
data: {
images: ["/images/link-01.png","/images/link-02.png","/images/ Default Avatar .jpeg"]
},
uploadImage() {
var that = this
wx.chooseImage({
count: 9,
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success:function(res) {
console.log(res)
// Set up images, The picture on the page is automatically modified
// that.setData({images: res.tempFilePaths})
// The default image + Selected pictures
that.setData({images: that.data.images.concat(res.tempFilePaths)})
}
})
},
/**
* Life cycle function -- Monitor page loading
*/
onLoad(options) {
},(4) recompile , Click on “ Please choose a picture ” after , Select a picture on the pop-up selection page ,

Click on “ open ” after , The display effect of the page is ,

边栏推荐
- redis在服务器linux下的启动的相关命令(安装和配置)
- MongoDB簡介
- Basic operations of mongodb [add, delete, modify, query]
- MongoDB安装 & 部署
- 简易版 微信小程序开发之页面跳转、数据绑定、获取用户信息、获取用户位置信息
- @Accessors annotation function specifies that the prefix follows the hump naming
- C # webrequest post mode, based on "basic auth" password authentication mode, uploads files and submits other data using multipart / form data mode
- npm : 无法将“npm”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
- numpy之 警告VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences
- Nanning water leakage detection: warmly congratulate Guangxi Zhongshui on winning the first famous brand in Guangxi
猜你喜欢

Recursion: depth first search

Limit of one question per day

navicat 导出数据库的表结构

简易版 微信小程序开发之页面跳转、数据绑定、获取用户信息、获取用户位置信息

Vs 2019 installation and configuration opencv

Avec trois. JS fait une scène 3D simple

PAT乙级“1104 天长地久”DFS优化思路
![Mongodb replication set [master-slave replication]](/img/2c/8030548455f45fa252062dd90e7b8b.png)
Mongodb replication set [master-slave replication]

Téléchargement et installation du client Filezilla

递归:快速排序,归并排序和堆排序
随机推荐
Avec trois. JS fait une scène 3D simple
Converts a timestamp to a time in the specified format
MySQL MAC download and installation tutorial
Node start server
Introduction to mongodb
Hutool动态添加定时任务
MongoDB基本操作【增、删、改、查】
Mongodb replication set [master-slave replication]
[mathematical logic] predicate logic (individual word | individual domain | predicate | full name quantifier | existence quantifier | predicate formula | exercise)
shardingsphere动态数据源
[AI practice] Application xgboost Xgbregressor builds air quality prediction model (I)
com. fasterxml. jackson. databind. Exc.invalidformatexception problem
Why does thread crash not cause JVM crash
Positioning (relative positioning, absolute positioning, fixed positioning, Z-index) 2022-2-11
[MySQL] the difference between left join, right join and join
Mysql Mac版下载安装教程
The file marked by labelme is converted to yolov5 format
用Three.js做一個簡單的3D場景
Latest version of NPM: the "NPM" item cannot be recognized as the name of a cmdlet, function, script file, or runnable program. Please check
别再用 System.currentTimeMillis() 统计耗时了,太 Low,StopWatch 好用到爆!