一、各种文件的用途
.json
后缀的 JSON
配置文件
.wxml
后缀的 WXML
模板文件
.wxss
后缀的 WXSS
样式文件
.js
后缀的 JS
脚本逻辑文件
二、全局配置补充
selectedColor | HexColor | 是 | tab 上的文字选中时的颜色,仅支持十六进制颜色 |
三、跳转到其他页面
<!-- 搜索 -->
<view class="scout {{top>=20? 'fixed' :'' }}" bindtap="newpage">
<image class='img' src='../../icons/icon.png'></image>
<input class='ipt' placeholder='请输入商家或商品名称' placeholder-class='place' disabled="true"></input>
</view>
实现
newpage:function(){
// 跳转到页面
wx.navigateTo({
url: '../scout/scout',
})
},
四、可滚动的页面
swiper
滑块视图容器。其中只可放置swiper-item组件,否则会导致未定义的行为。
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
indicator-dots | boolean | false | 否 | 是否显示面板指示点 |
vertical | boolean | false | 否 | 滑动方向是否为纵向 |
previous-margin | string | "0px" | 否 | 前边距,可用于露出前一项的一小部分,接受 px 和 rpx 值 |
next-margin | string | "0px" | 否 | 后边距,可用于露出后一项的一小部分,接受 px 和 rpx 值 |
display-multiple-items | number | 1 | 否 | 同时显示的滑块数量 |
skip-hidden-item-layout | boolean | false | 否 | 是否跳过未显示的滑块布局,设为 true 可优化复杂情况下的滑动性能,但会丢失隐藏状态滑块的布局信息 |
easing-function | string | "default" | 否 | 指定 swiper 切换缓动动画类型 |
bindchange | eventhandle | 否 | current 改变时会触发 change 事件,event.detail = {current, source} | |
bindtransition | eventhandle | 否 | swiper-item 的位置发生改变时会触发 transition 事件,event.detail = {dx: dx, dy: dy} |
滚动触发事件
bindscroll | eventhandle | 否 | 滚动时触发,event.detail = {scrollLeft, scrollTop, scrollHeight, scrollWidth, deltaX, deltaY} |
监听事件
scrollTopfun:function(e){
this.setData({
top: e.detail.scrollTop
})
// console.log(e.detail.scrollTop);
},
滚动到一定高度就固定
{{top>=20? 'fixed' :'' }}"
练习