日常小记--微信小程序
一,小程序当弹出弹框时,禁止弹框底部滚动,只滚动弹框内容
最外层遮罩层上加上:catchtouchmove="true"
,弹框里面需要滚动部分用 scroll-view
包裹,scroll-y="true"
<view wx:if="{{showTypeModal}}" class="mask" catchtouchmove="true">
<view class="modalContent" style="top: {{height}}px">
<view class="modalBox">
<view class="title">
<view class="type">
<view>{{modalTypeTitle}}</view>
<view>({{noticeTypes.length}})</view>
</view>
<view class="cancel" @tap="cancel">取消</view>
</view>
<SearchBar class="searchBarStl" @search.user="search" searchPlaceholder="请输入关键词搜索" showCancelBtn="hidden" />
<scroll-view class="list" scroll-y="true" wx:if="{{noticeTypes.length > 0}}">
<view class="{{title === '全部类型' ? 'selected' : 'default'}}" @tap="chooseType('全部类型')">全部类型</view>
<repeat for="{{noticeTypes}}" key="index" index="index" item="item">
<view class="{{title === item ? 'selected' : 'default'}}" @tap="chooseType({{item}})">{{item}}</view>
</repeat>
</scroll-view>
<view wx:else class="empty">暂无数据</view>
</view>
</view>
</view>
二,自定义头部导航栏
navigationStyle: 'custom',
注:
wx.getMenuButtonBoundingClientRect();
获取胶囊位置
async onLoad() {
if (!app.globalData.systeminfo) {
app.globalData.systeminfo = wx.getSystemInfoSync();
}
if (!app.globalData.headerBtnPosi) {
app.globalData.headerBtnPosi = wx.getMenuButtonBoundingClientRect();
}
let statusBarHeight = app.globalData.systeminfo.statusBarHeight // 状态栏高度
let headerPosi = app.globalData.headerBtnPosi // 胶囊位置信息
let btnPosi = { // 胶囊实际位置,坐标信息不是左上角原点
height: headerPosi.height,
width: headerPosi.width,
top: headerPosi.top - statusBarHeight, // 胶囊top - 状态栏高度
bottom: headerPosi.bottom - headerPosi.height - statusBarHeight, // 胶囊bottom - 胶囊height - 状态栏height (胶囊实际bottom 为距离导航栏底部的长度)
right: app.globalData.systeminfo.windowWidth - headerPosi.right // 这里不能获取 屏幕宽度,PC端打开小程序会有BUG,要获取窗口高度 - 胶囊right
}
var cusnavH = btnPosi.height + btnPosi.top + btnPosi.bottom // 导航高度
this.statusBarHeight = statusBarHeight; // 状态栏高度
this.navbarHeight = headerPosi.bottom + btnPosi.bottom; // 顶部导航栏高度
this.cusnavH = cusnavH; // title高度
this.$apply()
const height = headerPosi.bottom + btnPosi.bottom;
this.$emit('commonNavAttr', height)
}
三、get请求传的参数是拼接在url后面的,只能传String或者Number类型的参数;post请求可传对象类型的参数
return request({
url: `${apiHostMap.CP_HOST_WEB}/machine_shift_statement/auto-summary`,
method: 'POST',
headers: 'application/json',
body: JSON.stringify(params),
});
四、form 在任意场合针对特定值校验时使用form.validateFields(['lease_way_val'])
五、form 触发表单检验
form.validateFields().then(() => {
if (!isRule1Error && !isRule3Error && !isTeamRuleError && checkParams()) {
dispatch({
type: 'machineShiftStatements/operateStore',
payload: {
type,
}
})
}
});
六、合并单元格
// 合并单元格方法
const mergeCells = (text, list, filed, index) => {
if (index !== 0 && text === list[index - 1][filed]) {
return 0;
}
let rowSpan = 1;
for (let i = index + 1; i < list.length; i++) {
if (text !== list[i][filed]) {
break;
} else {
rowSpan++;
}
}
return rowSpan;
};
{
title: '操作',
key: 'work_record',
fixed: 'right',
width: 150,
render: (_, record, index) => {
return {
children:
<div className="txt-primary curp" onClick={() => setAdjust(record.date, record.extra_number)}>调整</div>,
props: {
// 该列按照 sheet_number 进行合并,只要sheet_number 相同就合并,autoSummaryList是接口返回的列表即所有数据
rowSpan: mergeCells(record.sheet_number, autoSummaryList, 'sheet_number', index),
},
};
},
}
git命令
stash
:存储临时代码。reset --soft
:软回溯,回退 commit 的同时保留修改内容。cherry-pick
:复制 commit。revert
:撤销 commit 的修改内容。reflog
:记录了 commit 的历史操作。