<span style="font-size:14px;">var app = getApp()
Page({
data:{
mode: 'aspectFit',
// src:'../images/timg1.jpg',
imgUrls:[
'../images/1.jpg',
'../images/2.jpg',
'../images/3.jpg',
'../images/4.jpg'
],
indicatorDots: true, //是否出现焦点
autoplay: true, //是否自动播放
interval: 2000, //自动播放时间间隔
duration: 1000, //滑动动画时间
userInfo: {}
},
onLoad:function(){
console.log('onLoad Test');
}
})</span>
<swiper indicator-dots = "{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}">
<block wx:for="{{imgUrls}}">
<swiper-item class="swiper_i">
<image src="{{item}}" mode="{{mode}}" class="slide-image" />
</swiper-item>
</block>
</swiper>
{
"navigationBarTitleText": "相册"
}
.slide-image{
width:100%;
height:100%;
}
.swiper_i{
text-align: center;
width:100%;
}
var app = getApp()
Page({
data:{
// text:"这是一个页面"
source: '',
tt:false
},
/**
* 选择相册或者相机 配合上传图片接口用
*/
onLoad: function() {
var that = this;
wx.chooseImage({
count: 1,
//original原图,compressed压缩图
sizeType: ['original'],
//album来源相册 camera相机
sourceType: ['album', 'camera'],
//成功时会回调
success: function(res) {
//重绘视图
that.setData({
source: res.tempFilePaths,
tt:true
})
/* var tempFilePaths = res.tempFilePaths
wx.uploadFile({
url: 'https://', //仅为示例,非真实的接口地址
filePath: tempFilePaths[0],
name: 'file',
formData:{
'user': 'test'
},
success: function(res){
var data = res.data
//do something
}
})*/
}
})
},
/*onHide:function(){
this.setData({
source:''
})
}*/
})
{
"navigationBarTitleText": "上传图片"
}
<view class="Container">
<image src="{{source}}" mode="aspectFit" class="image-i"/>
<block wx:if="{{tt}}">
<button type="primary" bindtap="listenerButtonChooseImage">确认上传</button>
</block>
</view>
/* pages/upload/upload.wxss */
.Container{
text-align:center;
width:100%;
}
.image-i{
width:100%;
height:100%;
}
{
"pages": [
"pages/index/index",
"pages/upload/upload"
],
"window": {
"navigationBarTextStyle": "black",
"navigationBarTitleText": "演示2",
"navigationBarBackgroundColor": "#fbf9fe",
"backgroundColor": "#fbf9fe"
},
"networkTimeout": {
"request": 10000,
"connectSocket": 10000,
"uploadFile": 10000,
"downloadFile": 10000
},
"tabBar": {
"list": [{
"pagePath": "pages/index/index",
"text": "显示图片",
"iconPath": "pages/images/icon_API.png",
"selectedIconPath": "pages/images/icon_API_HL.png"
},{
"pagePath": "pages/upload/upload",
"text": "上传",
"iconPath": "pages/images/icon_API.png",
"selectedIconPath": "pages/images/icon_API_HL.png"
}]
},
"debug": true
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有