支付宝小程序和微信小程序
1.文件后缀名
2.xml文件模板语言 a: wx:
3.api调用对象 my. wx.
4.网络请求接口 my.httpRequest wx.request
5.获取缓存数据 my.getStorage({‘key’:”}) wx.getStorage(”)
6.点击事件 onXXX–> bindXXX onTap bindtap
7.xml模板里面{{}}可以进行++ –运算,微信不可以
8.wx:for 需要同时有一个wx:key
9.swiper 微信小程序会有一个固定高度150,需要动态改变高度
<view class='swiper'>
<swiper indicator-dots="{{indicatorDots}}" vertical="{{vertical}}" autoplay="{{autoplay}}" duration="{{duration}}" interval='{{interval}}' bindchange="bindchange" circular="{{circular}}" style="height:{{imgheights[current]}}rpx;">
<block wx:for='{{imgList}}' wx:key="{{index}}">
<swiper-item>
<image src="{{item}}" data-id='{{index}}' class="slide-image" mode="widthFix" bindload="imageLoad"/>
</swiper-item>
</block>
</swiper>
</view>
.swiper image {
width: 100%;
height: auto;
}
data: {
//图片地址
imgList: ['/images/wyh-img_bg.png', '/images/wyh-img8.png', '/images/wyh-img_shop1.png', '/images/wyh-img_bg1.png'],
//是否采用衔接滑动
circular: true,
//是否显示画板指示点
indicatorDots: false,
//选中点的颜色
indicatorcolor: "#000",
//是否竖直
vertical: false,
//是否自动切换
autoplay: true,
//自动切换的间隔
interval: 2500,
//滑动动画时长毫秒
duration: 100,
//所有图片的高度
imgheights: [],
//图片宽度
imgwidth: 750,
//默认
current: 0
},
imageLoad: function (e) {//获取图片真实宽度
var imgwidth = e.detail.width,
imgheight = e.detail.height,
//宽高比
ratio = imgwidth / imgheight;
console.log(imgwidth, imgheight)
//计算的高度值
var viewHeight = 750 / ratio;
var imgheight = viewHeight;
var imgheights = this.data.imgheights;
//把每一张图片的对应的高度记录到数组里
imgheights[e.target.dataset.id] = imgheight;
this.setData({
imgheights: imgheights
})
},
bindchange: function (e) {
// console.log(e.detail.current)
this.setData({ current: e.detail.current })
},
10.网络请求如果是post方式,必须设置header
header['content-type']
为 application/x-www-form-urlencoded
header: {
"Content-Type": "application/x-www-form-urlencoded" //post请求设置
},
11.导航栏颜色
支付宝小程序通过js 可以设置
维信小程序在json文件中设置,注意单个页面设置的时候不能写window