function promise(fn) { return function (obj = {}) { return new Promise((resolve, reject) => { obj.success = res => resolve(res); obj.fail = res => reject(res); fn(obj); }) } } ... 调用方式: utils.promise(wx.request)({ url: ... }).then(response => { ... }) ...
.elem { /* 元素本身添加样式 */ position: relative; /* 为了后面的伪元素以本元素为定位基准 */ z-index: 10; /* 渲染在伪元素之上 */ /* 其它样式,大小,字体等 */ } .elem::after { /* 给元素添加::after伪元素并设置为半透明:*/ content: ""; position: absolute; left: 0; background-color: white; opacity: 0.2; /* 其它样式,大小应和主元素一致 */ }
/* 仅供测试,发布版请删除 */ view,icon,text,rich-text,progress,image,button,textarea,open-data,navigator,canvas,checkbox,form,input,label,picker,radio,slider,switch { outline: 1px dashed lightblue; }
.mainbg { background: -webkit-linear-gradient(left,#18b6ff,#aa29ff); background: linear-gradient(left,#18b6ff,#aa29ff); }
{ height: calc(100vh - 300rpx); }