• mini program 3


    获取textarea的值,通过插值获取

    <textarea bindblur="bindTextAreaBlur" auto-height placeholder="请输入texterea内容" value="{{ceshi}}" />
    
     bindTextAreaBlur: function(e) {
         this.setData({
          ceshi:e.detail.value
         }) 
    
      },
    

    图片上传

    <view class="comment" wx:if="{{showCommentModal && firstPop}}">
      <form bindsubmit="submitComment">
      <view class='comment-content'>
        <view class='comment-input'>
          <textarea placeholder='说说你的体验感受' value="{{content123}}" bindblur="gainContent"></textarea>
        </view>
        <view class='photo-wrap'>
              <view wx:for="{{files}}" wx:key="{{index}}" class='uploadItem'>
                <image class="weui-uploader__img" src="{{item}}" mode="aspectFill" bindtap="previewImage"  id="{{index}}" />
                <text class='deleteImg' bindtap='deleteImg' data-index='{{index}}'>删除</text>
              </view>
            <view class='uploader' bindtap='uploderImg' data-flie='imgFile'></view>
        </view>
      </view>
      <view class='submit'>
        <button bindtap='closeCommentModal' class='closeCommentModal'>关闭</button>
        <button formType="submit" class='submit123'>提交</button>
      </view>
        </form>
    </view>
    
      uploderImg: function (e) {
        var that = this;
        wx.chooseImage({
          sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
          sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
          success: function (res) {
            // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片
            that.setData({
              files: that.data.files.concat(res.tempFilePaths)
            });
            console.log(res)
            for (var img_item = 0; img_item < res.tempFilePaths.length;img_item++){
              wx.uploadFile({
                url: app.globalData.hostname + "/api/event/util/addFile",
                filePath: res.tempFilePaths[img_item],
                name: 'file',
                header: { "Content-Type": "multipart/form-data", 'accept': 'application/json' },
                formData: {
                  appkey: app.globalData.appkey,
                  appsecret: app.globalData.appsecret,
                },
                success: function (res2) {
                  res2.data = JSON.parse(res2.data);
                  that.data.fileIds.push(String(res2.data.data));
                  that.setData({
                    fileIds: that.data.fileIds
                  });
                }
              })
            }
          }
        })
      },
    
  • 相关阅读:
    ECMAScript——引用数据类型之date
    ECMAScript——引用数据类型之RegExp
    ECMAScript——引用数据类型之array
    ECMAScript——引用数据类型之object
    ECMAScript——基本数据类型之null和undefined
    ECMAScript——基本数据类型之boolean
    ECMAScript——基本数据类型之string
    ECMAScript——基本数据类型之number
    libgdx 3D Bullet 碰撞检测二
    libgdx 3D Bullet 碰撞检测一
  • 原文地址:https://www.cnblogs.com/cyany/p/9894113.html
Copyright © 2020-2023  润新知