要求每两张图片后插入一个广告,请问这怎么做,有偿,微信 jinnchen94
setAdCustomZwy(items, pageNum) {
if (!不符合条件) {
return items;
}
let start;
let space = this.config.space - 1;
if (pageNum == 1) {
start = this.config.firstAd - 1
} else {
start = this.isStart;
}
while (items.length > start) {
items.splice(start, 0, {
type: 'adCustom',
title: 'adCustom999',
videoId: 0
})
start = space + start + 1;
}
this.isStart = start - items.length;
return items;
},
var arr = [...Array(10).keys()];//生成0-9
//[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
var obj = 'ad';//要添加的数据
arr.reduce((acc,cur,idx)=>(acc.push(cur),idx%2 && acc.push(obj),acc),[]);
//[0, 1, "ad", 2, 3, "ad", 4, 5, "ad", 6, 7, "ad", 8, 9, "ad"]
10 回答11.7k 阅读
2 回答3.2k 阅读✓ 已解决
2 回答4.3k 阅读✓ 已解决
4 回答4.6k 阅读✓ 已解决
3 回答1.9k 阅读✓ 已解决
4 回答2.1k 阅读✓ 已解决
2 回答1.7k 阅读✓ 已解决