激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務(wù)器之家:專(zhuān)注于服務(wù)器技術(shù)及軟件下載分享
分類(lèi)導(dǎo)航

node.js|vue.js|jquery|angularjs|React|json|js教程|

服務(wù)器之家 - 編程語(yǔ)言 - JavaScript - js教程 - 微信小程序選擇圖片控件

微信小程序選擇圖片控件

2022-01-04 16:33小雅雅家的小凱凱吖 js教程

這篇文章主要為大家詳細(xì)介紹了微信小程序選擇圖片控件,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了微信小程序選擇圖片控件的具體代碼,供大家參考,具體內(nèi)容如下

微信小程序選擇圖片控件

xml:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<loading hidden="{{loadingHidden}}">
 加載中...
</loading>
<view class="add_carimg">
 <block>
 <view class="load_iamge">
 <text class="load_head_text">上傳施工車(chē)輛照片</text>
 <text class="load_foot_text">{{imgbox.length}}/2</text>
 </view>
 <view class='pages'>
 <view class="images_box">
 <block wx:key="imgbox" wx:for="{{imgbox}}">
  <view class='img-box'>
  <image class='img' src='{{item}}' data-message="{{item}}" bindtap="imgYu"></image>
  <view class='img-delect' data-deindex='{{index}}' bindtap='imgDelete1'>
  <image class='img' src='/pages/images/delete_btn.png'></image>
  </view>
  </view>
 </block>
 <view class='img-box' bindtap='addPic1' wx:if="{{imgbox.length<2}}">
  <image class='img' src='/pages/images/load_image.png'></image>
 </view>
 </view>
 </view>
 </block>
</view>
<view>
 <button class="work_btn" bindtap="shanggang">上崗</button>
</view>

css: 

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
.work_btn {
 width: 60%;
 height: 35px;
 line-height: 35px;
 margin-top: 15px;
 border-radius: 5px;
 font-size: 30rpx;
 color: white;
 background-color: rgb(2, 218, 247);
}
 
.work_btn:active {
 width: 60%;
 height: 35px;
 line-height: 35px;
 margin-top: 15px;
 border-radius: 5px;
 font-size: 30rpx;
 color: white;
 background-color: rgb(151, 222, 231);
}
 
/*********/
 
.load_iamge {
 width: 100%;
 height: 30px;
 margin-top: 10px;
 display: flex;
 flex-direction: row;
}
 
.load_head_text {
 width: 95%;
 height: 20px;
 margin-bottom: 5px;
 margin-top: 5px;
 
 
}
 
.load_foot_text {
 width: 5%;
 height: 20px;
 margin-right: 15px;
 margin-top: 5px;
 margin-bottom: 5px;
 float: right;
 
}
 
.pages {
 width: 98%;
 margin: auto;
 overflow: hidden;
}
 
/* 圖片 */
.images_box {
 width: 100%;
 display: flex;
 flex-direction: row;
 flex-wrap: wrap;
 justify-content: flex-start;
 background-color: white;
}
 
.img-box {
 border: 2rpx;
 border-style: solid;
 border-color: rgba(170, 167, 167, 0.452);
 width: 200rpx;
 height: 200rpx;
 margin-left: 35rpx;
 margin-top: 20rpx;
 margin-bottom: 20rpx;
 position: relative;
}
 
/* 刪除圖片 */
.img-delect {
 width: 50rpx;
 height: 50rpx;
 border-radius: 50%;
 position: absolute;
 right: -20rpx;
 top: -20rpx;
}
 
.img {
 width: 100%;
 height: 100%;
}

js:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
Page({
 
 /**
 * 頁(yè)面的初始數(shù)據(jù)
 */
 data: {
 tempFilePaths: '',
 imgbox: [], //選擇圖片
 fileIDs: [], //上傳云存儲(chǔ)后的返回值
 src: 0,
 },
 
 onLoad: function (options) {
 
 
 },
 //圖片點(diǎn)擊事件
 imgYu: function (event) {
 var that = this;
 
 console.log(event.target.dataset.message + "這是啥");
 var src = event.target.dataset.message;
 //圖片預(yù)覽
 wx.previewImage({
 current: src, // 當(dāng)前顯示圖片的http鏈接
 urls: [src] // 需要預(yù)覽的圖片http鏈接列表
 })
 }, // 刪除照片 &&
 imgDelete1: function (e) {
 let that = this;
 let index = e.currentTarget.dataset.deindex;
 let imgbox = this.data.imgbox;
 imgbox.splice(index, 1)
 that.setData({
 imgbox: imgbox
 });
 },
 // 刪除照片 &&
 imgDelete1: function (e) {
 let that = this;
 let index = e.currentTarget.dataset.deindex;
 let imgbox = this.data.imgbox;
 imgbox.splice(index, 1)
 that.setData({
 imgbox: imgbox
 });
 },
 // 選擇圖片 &&&
 addPic1: function (e) {
 var imgbox = this.data.imgbox;
 console.log(imgbox)
 var that = this;
 var n = 2;
 if (2 > imgbox.length > 0) {
 n = 2 - imgbox.length;
 } else if (imgbox.length == 2) {
 n = 1;
 }
 wx.chooseImage({
 count: n, // 默認(rèn)9,設(shè)置圖片張數(shù)
 sizeType: ['original', 'compressed'], // 可以指定是原圖還是壓縮圖,默認(rèn)二者都有
 sourceType: ['album', 'camera'], // 可以指定來(lái)源是相冊(cè)還是相機(jī),默認(rèn)二者都有
 success: function (res) {
  // console.log(res.tempFilePaths)
  // 返回選定照片的本地文件路徑列表,tempFilePath可以作為img標(biāo)簽的src屬性顯示圖片
  var tempFilePaths = res.tempFilePaths
  console.log('路徑' + tempFilePaths);
  if (imgbox.length == 0) {
  imgbox = tempFilePaths
  } else if (2 > imgbox.length) {
  imgbox = imgbox.concat(tempFilePaths);
  }
  that.setData({
  imgbox: imgbox,
  imgnum: imgbox.length
  });
 }
 })
 },
 
 //圖片
 imgbox: function (e) {
 this.setData({
 imgbox: e.detail.value
 })
 },
 
})

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。

原文鏈接:https://blog.csdn.net/w_s_x_b/article/details/112756412

延伸 · 閱讀

精彩推薦
  • js教程JS代碼實(shí)現(xiàn)頁(yè)面切換效果

    JS代碼實(shí)現(xiàn)頁(yè)面切換效果

    這篇文章主要為大家詳細(xì)介紹了JS代碼實(shí)現(xiàn)頁(yè)面切換效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下...

    _Adoph9302021-12-29
  • js教程ES6字符串的擴(kuò)展實(shí)例

    ES6字符串的擴(kuò)展實(shí)例

    這篇文章主要介紹了ES6字符串的擴(kuò)展實(shí)例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小...

    知否5512021-12-16
  • js教程js實(shí)現(xiàn)隨機(jī)點(diǎn)名

    js實(shí)現(xiàn)隨機(jī)點(diǎn)名

    這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)隨機(jī)點(diǎn)名,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下...

    搬磚大法10032022-01-04
  • js教程原生JS運(yùn)動(dòng)實(shí)現(xiàn)輪播圖

    原生JS運(yùn)動(dòng)實(shí)現(xiàn)輪播圖

    這篇文章主要為大家詳細(xì)介紹了原生JS運(yùn)動(dòng)實(shí)現(xiàn)輪播圖,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下...

    Bean_s9362021-12-24
  • js教程微信小程序 接入騰訊地圖的兩種寫(xiě)法

    微信小程序 接入騰訊地圖的兩種寫(xiě)法

    這篇文章主要介紹了微信小程序 接入騰訊地圖的兩種寫(xiě)法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參...

    木早長(zhǎng)泉8722021-12-30
  • js教程如何在JavaScript中正確處理變量

    如何在JavaScript中正確處理變量

    這篇文章主要介紹了如何在JavaScript中正確處理變量,幫助大家更好的理解和使用JavaScript,感興趣的朋友可以了解下...

    瘋狂的技術(shù)宅10682021-12-20
  • js教程原生JavaScript實(shí)現(xiàn)隨機(jī)點(diǎn)名表

    原生JavaScript實(shí)現(xiàn)隨機(jī)點(diǎn)名表

    這篇文章主要為大家詳細(xì)介紹了原生JavaScript實(shí)現(xiàn)隨機(jī)點(diǎn)名表,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下...

    棟棟很優(yōu)秀啊9722021-12-31
  • js教程JavaScript實(shí)現(xiàn)消消樂(lè)的源代碼

    JavaScript實(shí)現(xiàn)消消樂(lè)的源代碼

    這篇文章主要介紹了JavaScript實(shí)現(xiàn)消消樂(lè)-源代碼,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以...

    代碼100分12002021-12-30
主站蜘蛛池模板: 黄色的视频在线观看 | 国产精品99久久久久久久vr | 中文字幕激情视频 | 一色屋任你操 | 欧美一级黄色片在线观看 | 日韩黄色免费在线观看 | 成人免费一区二区三区 | 亚洲综合色视频在线观看 | 99爱精品在线 | 国产精品久久亚洲 | 狠狠干伊人网 | 欧美一区二区三区中文字幕 | 精品久久久久久久久中文字幕 | 请播放一级毛片 | 中文字幕亚洲一区二区三区 | av电影免费观看 | 精品久久久久久久久久久久久久 | 成人在线免费观看视频 | 日本在线观看视频网站 | 国产成人精品区 | 久草视频2 | 国产精品毛片无码 | 青青草成人影视 | 欧美精品一二三区 | 免费毛片在线 | 鲁丝片一区二区三区免费入口 | 久久在线| 日韩视频一二三 | 成人欧美视频 | 色就色 综合偷拍区91网 | 手机国产乱子伦精品视频 | 成人一级视频在线观看 | 久久久午夜电影 | 成人精品视频在线 | 久久密| 全部免费毛片 | 日本搞逼视频 | 九九热在线视频观看这里只有精品 | 久久久三级免费电影 | 一级片免费在线 | 91av在线免费播放 |