遮挡层时防止触摸穿透
<view class="content" :catchtouchmove="true">
加载中。。。
</view>
模糊背景
.content_BG{
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
image{
width: 100%;
height: 100%;
}
filter: blur(8rpx);
opacity: 0.3;
}
文本显示两行,多余显示省略号
display:-webkit-box;
-webkit-box-orient:vertical;
-webkit-line-clamp:2;
overflow:hidden;
三元表达式动态添加类
<ordering :class="[activeIndex === 0 ? 'successClass' : 'errClass']"></ordering>
数组去重,数组去空, 数组合并
let oldArr = [1, 1, 2, 2, 2, 3, '', '']
//数组去重
let newArr = Array.from(new Set(oldArr))
//数组去重 2
computed:{
calculation(){
// 监听总价
// 1数组对象去重 :累加器:reduce()
let arr = {}
let arrdata = this.arrtotalPrice.reduce((preVal,curVal)=>{
arr[curVal.indexs] ? '' : arr[curVal.indexs] = true && preVal.push(curVal)
return preVal
},[])
}
//数组去空值
let newArr2 = newArr2.filter(item => item)
//数组合并
let arr = ['全部', ...newArr]
给数组中的对象添加键值
newValue.map( item => {
let key = 'amount'
let num = 0
return item[key] = num
})
给文字添加下划线 删除线
text-decoration: line-through;
JS去除浮点数
let allPrice = this.count * Discount
//去除总价浮点数
let TotalNum = parseFloat((allPrice).toFixed(10))
Koa 解决跨域问题
- npm下载 koa-cors
$ npm install koa-cors
- 主函数写如下代码
var koa = require('koa');
var route = require('koa-route');
var cors = require('koa-cors');
var app = koa();
app.use(cors());
app.use(route.get('/', function() {
this.body = { msg: 'Hello World!' };
}));
app.listen(3000);
关键代码
var cors = require('koa-cors');
app.use(cors());
网友评论