盒子排列
.container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
display: flex;
flex-direction: column;
justify-content: space-between;
div{
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(2, 64rpx);
grid-gap: 28rpx;
}
垂直水平居中
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
div垂直居中文字靠左
.add-flight-info {
display: flex;
flex-direction: column;
justify-content: center; /* 垂直居中 */
align-items: flex-start; /* 水平靠左对齐 */
text-align: left; /* 文本左对齐 */
font-weight: 500;
font-size: 16px;
color: #200e32;
}
小程序scroll-view滚动条隐藏
::-webkit-scrollbar { width: 0; height: 0; color: transparent; }
——————————————————————————————————————————————————————————————————————
//overflow: auto;滚动条隐藏
::-webkit-scrollbar {
display: none;
}
vue项目
https://www.cnblogs.com/66-RAKU/p/15940119.html
传参
wx.navigateTo({
url: `./verifiedDetail/index?shopUid=${shopUid}&cardUid=${cardUid}`,
})
wx.navigateTo({
url:"www.baidu.com?id_1=" + 1 + "&id_2=" + 2
})
http.request(config.api.cartsListUrl + `?storeId=${ wx.getStorageSync('storeInfo').storeId}&diningMode=${'DINE_IN'}`, {}, 'DELETE').then(res => {
console.log('清空购物车成功: ', res)
that.getCartDetail()
}).catch(err => {
console.log('清空购物车失败: ', wx.getStorageSync('stores').id)
common.showModal(err)
})
this.setData({
[`cartData.items[${e.detail.value}].quantity`]: quantityM
})
wx.showModal({
title: '提示',
content: `确定${status?'上':'下'}架该商品吗?`,
success(res) {
if (res.confirm) {
console.log(`用户点击${status?'上':'下'}架确定`)
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
跳出map
try {
this.data.packageList.map(res => {
optionQuantity = res
var opo = res.values.filter(v => v.selStatus)
if (opo.length < 1) {
wx.showModal({
title: '提示',
content: '请选择' + res.name,
confirmText: '确定',
showCancel: false,
})
throw 'Custom Exception'
}
} catch (e) {
console.log(e)
}
js数组里面的值相加
var array = [1,2,3,4,5,6];
var sum = array.reduce(function(a,b){
return parseInt(a) + parseInt(b);
},0);
console.log(sum)
小程序符号替换
JS写法
var str ='2020-8-3 18:18:23';
//以下两种任选一种
str.replace(new RegExp('-','g'),'/');
str.replace(/-/g,'/');
console.log(str);
WXS写法
var datewxs=function(str){
var newdate = str.replace(getRegExp('-','g'),'/');
return newdate;
}
module.exports = {
datewxs: datewxs
}
<!--wxml引用-->
<wxs module="datewxs" src="../../utils/datewxs.wxs"></wxs>
<view>{{datewxs.datewxs('2020-8-3 18:18:23')}}</view>
map跳出
try {
this.data.packageList.map(res => {
var opo = res.values.filter(v => v.selStatus)
if (opo.length < 1) {
wx.showModal({
title: '提示',
content: '请选择' + res.name,
confirmText: '确定',
showCancel: false,
})
nullJudge = false
throw 'Custom Exception'
}else{
nullJudge = true
}
})
} catch (e) {
console.log(e)
}
if (!nullJudge) return
let attributes = []
var arrays = this.data.packageList.map(res => res.values)
arrays.map(val => {
val.filter(r => {
if (r.selStatus === true) {
attributes.push(r)
}
})
})
页面栈
跳转的页面
var pages = getCurrentPages(); //当前页面
var prevPage = pages[pages.length - 2]; //上一页面
prevPage.setData({
//直接给上一个页面赋值
productName: detail.name,
productId: detail.index
});
wx.navigateBack({
delta: 1
})
返回上一个页面
onShow() {
let pages = getCurrentPages();
let currPage = pages[pages.length - 1];
if (currPage.data.productId) {
this.data.supplierList['product_code'] = currPage.data.productId
this.data.supplierList['product_category'] = currPage.data.productName
this.setData({
supplierList: this.data.supplierList
});
}
}
循环添加
nav.forEach((v,i)=>i==index?v.isactive=true:v.isactive=false);
git创建本地分支命令,git创建新分支的命令
小程序获取当前时间
在写获取系统当前的时间的时候,我们首先要前了解一下JS中的Date对象的用法。
//用于获取年份
1、Date().getFullYear()
//获取当前月份,注意返回值是0-11,需要在后面+1
2、Date().getMonth()
//获取当前日
3、Date().getDate()
//获取当前时刻
4、Date().getHours()
//获取分钟
5、new Date().getMinutes()
//获取秒数
6、new Date().getSeconds()
getNowDate:function(e){
var timestamp = Date.parse(new Date());
var date = new Date(timestamp);
//获取年份
var Y =date.getFullYear();
//获取月份
var M =date.getMonth()+1;
//获取当前天
var D = date.getDate();
//获取当前小时
var H = date.getHours()
console.log("当前时间:" + Y + '年' + M +'月' + D +'日' + H+'时');
},
onShow: function () {
this.getNowDate()
},
小程序正则
[ ] 转换为对象格式
// 转换为对象格式
let objectData = {};
e.currentTarget.dataset.params.forEach(item => {
objectData[item.name] = item.value;
});