开启文本框自动高度后,真机文本框一行只能显示一个字
发布于 6 年前 作者 rliang 5524 次浏览 来自 问答

开启文本框自动高度后,真机文本框一行只能显示一个字,开发者工具正常。

<view class="weui-cell">
        <view class="weui-cell__bd">
          <textarea class="weui-textarea" bindblur="contentInput" bindinput="contentInput" placeholder="点击输入要发布的内容" value="{{content}}" style="height: 3.3em;width:100%" auto-height="true" maxlength="{{content_max}}" auto-focus="true" fixed="true"/>
          <view class="weui-textarea-counter">{{content_count}}/{{content_max}}</view>
        </view>
      </view>
8 回复

目前是改成固定高度选用着了,等着问题解决了再换成自动高度,还有自动高度能否设置个默认最低高度,不然默认都是一行,界面会不好看。超过最低高度或者最低行数后,再自动增高,这样会不叫好点。

没有另外的css样式控制这个textarea宽度

宽度是100%,代码里有写style=“height: 3.3em;width:100%”

<view class="weui-cell">
        <view class="weui-cell__bd">
          <textarea class="weui-textarea" bindblur="contentInput" bindinput="contentInput" placeholder="点击输入要发布的内容" value="{{content}}" style="height: 3.3em;width:100%" auto-height="true" maxlength="{{content_max}}" auto-focus="true" fixed="true"/>
          <view class="weui-textarea-counter">{{content_count}}/{{content_max}}</view>
        </view>
      </view>
/**
   * 页面的初始数据
   */
  data: {
    title: '发布',
    pageHidden: false,//页面隐藏显示状态
    loading: false,//加载状态
 
    category_id: 0,//分类ID
    category_name: '',//分类名称
 
    content: '', //内容
    phone: '',//手机号
    location: {},//定位信息
 
    content_count: 0,//文本字数
    content_max: 120,//文本最大字数
 
    uploads: [],//已上传的图片地址
    uploadmax: 9,//最大图片数
    uploadall: false,//是否全部上传完成
    submiting: false,//提交状态
 
 
 
    switchTop: false,//是否置顶
    pay_fee: 0,//发布金额
    pay_top: [],//置顶信息
    top_max: 0,//最大置顶数
    top_surplus: 0,//剩余置顶数
    array_top: [],//选项数组
    pay_day: 0,//置顶天数
 
  },

这个问题的相关代码能否发一下,我看能否重现

自动高度后,style就无效了,文档里有写。

请确认下textarea的宽度是否正确?

你设置min-height行不行呢

回到顶部