日常bug总汇
图片与图片之间有缝隙
- 该图片为块级元素
- 设置body的line-height:0;
art-template模板遍历对象
html部分:
<!-- 渲染模板显示的位置 -->
<div id="content"></div>
模板js部分
<!-- 引入对应的模板 -->
<script src="https://www.dfs168.com/output/js/template.js"></script>
<!-- 模板使用放在script中,给script标注id -->
<script type="text/html" id="contenttpl">
<ul>
{{each list as value i}}
<li>
<div class="left">
<img src="{{value.goods_image}}"
alt="">
</div>
<div class="right">
<div class="tit">
{{value.goods_name}}
</div>
<div class="trait">{{value.tag}}</div>
<div class="price">
<div class="now">活动价 <i> ¥ </i><span>{{value.goods_price}}</span></div>
<del class="old">原价<span>¥{{value.goods_marketprice}}</span></del>
</div>
<div class="pay"><a href="{{value.pc_url}}">立即购买 ></a></div>
</div>
</li>
{{ /each }}
</ul>
</script>
js调用
<script>
$.ajax({
url: "https://www.dfs168.com/wgfd/goods/jsons?id=12yuedongjimaizengzhuanchang",
type: 'GET',
data: {},
dataType: 'jsonp',
jsonp: 'callback',
contentType: "application/javascript;utf-8",
jsonpCallback: 'flightHandler',
success: function (data) {
var html = template('contenttpl', {list:data});
document.getElementById('content').innerHTML = html;
}
});
</script>
注:使用模板可以遍历数组也可以遍历对象,遍历对象的话,低版本需要包裹.
vue中使用lsee
npm install less less-loader --save
- 配置对应的loader
myObject>build>webpack.base.conf.js中配置
{
test: /\.less$/,
loader: "style-loader!css-loader!less-loader",
}
- 页面中使用:在组件中的style 添加lang=“less”
<!-- 在组件中的style 添加lang="less" -->
<style scoped lang="less">
.search {
display: flex;
.input {
flex: 1;
color: #fff;
line-height: 30px;
background-color: rgba(11, 59, 11, 0.6);
display: flex;
border-radius: 5px;
input {
border: none;
display: block;
color: #fff;
background: none;
height: 30px;
font-size: 16px;
line-height: 32px;
flex: 1;
outline: none;
}
}
.icon-dianhua {
display: block;
width: 30px;
height: 32px;
line-height: 32px;
font-size: 30px;
text-align: center;
margin-left: 10px;
color: #fff;
background-color: rgba(11, 59, 11, 0.6);
border-radius: 5px;
}
}
</style>
微信分享问题
1.分享只能分享当前页
2.ios不会重新加载相同带参数地址,使用vue下$router.push()或者replace(),不会修改url地址,如果分享出去的地址时带参数的,需要使用强制刷新赋值
分享制作
<!--- 导入分享文件 --->
<script src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
function is_weixn(){
var ua = navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i)=="micromessenger") {
return true;
} else {
return false;
}
}
if (is_weixn()) {
let shareUrl = window.location.href;
var data = {'url': opt.share_url};
console.log('shareUrl',shareUrl)
Api.common.getConfig(data).then(res=>{
var wxConfig = res;
wx.config(wxConfig);
wx.ready(function () {
let shareIndex = {
title: '分享标题 ',
desc: '分享描述 ',
link: shareUrl,
imgUrl: '分享图标'
};
wx.onMenuShareAppMessage(shareIndex);
wx.onMenuShareTimeline(shareIndex);
});
})
}
</script>
php混合开发时,严格执行编译语法
混合开发出现测试环境无报错,线上出现问题,主要原因是因为线上代码强压缩后,代码中缺少闭合,部分手机(特别安卓机)会因为报错中断js执行,出现失败的情况.导入debug后,打印错误->Uncaught SyntaxError: Unexpected end of input;
vue项目打包不存掉部分样式
h3 {
height: .72rem;
font-size: .28rem;
line-height: 1.29;
color: #555;
padding: 0 .16rem;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
margin-top: .15rem;
}
原因
-webkit-box-orient: vertical 这个属性被 optimize-css-assets-webpack-plugin插件在编译时删除掉了
解决办法
h3 {
-webkit-box-orient: vertical;
}