当前位置:网站首页>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 ,
边栏推荐
- Summary of determinant knowledge points in Chapter 1 of Linear Algebra (Jeff's self perception)
- redis高级应用【密码防护、数据持久化、主从同步、哨兵模式、事务】【暂未完成(半成品)】
- Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
- numpy之 警告VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences
- Application of derivative in daily question
- Stepping on pits and solutions when using inputfilter to limit EditText
- [mathematical logic] propositional logic (propositional logic reasoning | formal structure of reasoning | inference law | additional law | simplification law | hypothetical reasoning | refusal | disju
- MongoDB简介
- Lvgl usage experience
- Summary of matrix knowledge points in Chapter 2 of Linear Algebra (Jeff's self perception)
猜你喜欢
Mongodb installation & Deployment
Pytorch轻量级可视化工具wandb(local)
别再用 System.currentTimeMillis() 统计耗时了,太 Low,StopWatch 好用到爆!
User value is the last word in the competition of mobile phone market
Vs 2019 configuration du moteur de génération de tensorrt
机械臂速成小指南(八):运动学建模(标准DH法)
navicat 导出数据库的表结构
Section 26 detailed explanation and demonstration of IPSec virtual private network configuration experiment - simulation experiment based on packettracer8.0
MongoDB簡介
Ansible introduction [unfinished (semi-finished products)]
随机推荐
为什么线程崩溃不会导致 JVM 崩溃
Lvgl usage experience
动态规划:最长回文子串和子序列
shardingsphere动态数据源
释放数据力量的Ceph-尚文网络xUP楠哥
Vs 2019 configuration tensorrt
Vs 2019 configuration du moteur de génération de tensorrt
New programmers use the isXXX form to define Boolean types in the morning, and are discouraged in the afternoon?
Stop using system Currenttimemillis() takes too long to count. It's too low. Stopwatch is easy to use!
navicat 导出数据库的表结构
Positioning (relative positioning, absolute positioning, fixed positioning, Z-index) 2022-2-11
Model transformation onnx2engine
Table structure of Navicat export database
Limit of one question per day
二进制流转换成字节数组
静态网页 和 动态网页的区别 & WEB1.0和WEB2.0的区别 & GET 和 POST 的区别
简易版 微信小程序开发之for指令、上传图片及展示效果优化
Téléchargement et installation du client Filezilla
[MySQL] the difference between left join, right join and join
Some preliminary preparations for QQ applet development: make an appointment for a development account, download and install developer tools, and create QQ applet