取小数点
let number = 1.548485
// 如果不取整将round去掉。
let str = (Math.round(number * 100) + '').split('.')[0].split('')
<!-- 后两位 -->
str.splice(-2, 0, '.')
number = str.join('')
if(!number.split('.')[0]) {
number = '0' + number
}
console.log(number)
<!-- 1.55 -->
css盒子问题
padding向内 盒子内容会变小
box-sizing: border-box;
padding向外 盒子内容保持不变
box-sizing: content-box;
文本不换行显示省略号,使用max-width,会更加友好一点,不会影响到其它布局
max-width: 180px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
scroll-view组件
<scroll-view scroll-y="true" style="height: {{height}}px;">
</scroll-view>
let that = this
// 获取当前页面高度
wx.getSystemInfo({
success(res) {
// 修改或者获取元素的dom
that.setData({
height: res.windowHeight - 60
})
}
})