文本超出几行显示省略号

 

<view class='content'>
    <view class='c_text' id="box" style='-webkit-line-clamp:{{lineclamp}}'>
      本酒店好霸道个地方不化的风格股的方法反反复复部分 地方改变地方vadfvdfjfbiiiuioulkdaflgvbdfgbvf 胡椒粉IDGV不vbfudioshbdfb电饭锅电饭锅电饭锅 大风过后如果喝好中发现不对覅后在低V胡答复VB 胡椒粉IDGV不vbfudioshbdfb电饭锅电饭锅电饭锅 大风过后如果喝好中发现不对覅后在低V胡答复VB
    </view>
    <view class='appear' hidden='{{status==0}}'>
      <button type='primary' bindtap='isclick' hover-class='none'>显示全部</button>
    </view>
  </view>
.content{
  padding: 20rpx;
}
.c_text{
  font-size: 32rpx;
  display: -webkit-box;
  text-overflow:ellipsis;
  overflow: hidden;
  word-break: break-all;
  white-space: pre-line;
  -webkit-box-orient: vertical;
  /*-webkit-line-clamp:2;*/
  text-indent:2em;
  color: #515151;
}
.appear{
  margin-top: 20rpx;
  border-top: 1px solid #ddd;
}
.appear button{
  margin:30rpx auto;
  width:30%;
  font-size: 30rpx;
  background:transparent;
  color:#999; 
}

 

data: {
    lineclamp:6,

  },
  boxheight(e){
    var that=this;
    var query = wx.createSelectorQuery();
    query.select('#box').boundingClientRect()
    query.exec(function (res) {
      console.log(res[0].height);
      var boxheight = res[0].height;
      if (boxheight<140){
        var status=0;
      }
      that.setData({
        boxheight: boxheight,
        status: status
      })
    })
  },
  isclick(){
    this.setData({
      lineclamp:1000,
      status:0
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.boxheight();
  },

类似这种,样子很丑,很久很久之前测试写的,一直没用上,有好的方法,欢迎指正啊

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值