zoukankan      html  css  js  c++  java
  • 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
                  });
                }
              })
            }
          }
        })
      },
    
  • 相关阅读:
    在idea的控制台进行git pull 或者git push的时候每次都要输入用户名和密码的解决办法
    js中和html中onclick绑定函数要不要加括号的问题
    ElementUI checkbox组件中的indeterminate 状态
    js之常见问题--for循环中为什么点击总是弹出最后一个i
    vue中watch监听浏览器窗口大小的改变
    Duplicate keys detected: '0'. This may cause an update error.
    数组对象去重总结
    【转载】git 回退版本
    K8s
    go 记录日志到Elk
  • 原文地址:https://www.cnblogs.com/cyany/p/9894113.html
Copyright © 2011-2022 走看看