Vue发送图片(base64)

 点击图片按钮,选择本地图片进行发送


From.vue


<template>
    <a-spin :spinning="confirmLoading">
        <a-row>
          <a-col :span="18" :style="'height:750px;'">
            <a-card type="inner" title="工单服务" :style="'background: RGB(247,247,247);height:100%;'">
              <chat ref="chat"></chat>
              <div class="hover-pr" style="text-align: right; margin-bottom: 5px; float: right;" @click="complaint">
                <a-icon type="dislike" />&nbsp;我要投诉
              </div>
              <div @click="uploadImg">
                <img style="width: 20px;height: 20px;" src="@/assets/picture.png"/>
              </div>
              <a-textarea rows="4" placeholder="输入内容" v-model="reply.replyContent" contenteditable @keyup.enter.exact="submit" @keydown.enter.exact="handleKeydown"/>
              <a-button type="primary" :style="'float: right;margin-top:5px;'" @click="sendReplyContent" :disabled="model.issueState === '1'">发送</a-button>
            </a-card>
          </a-col>
        </a-row>
    </a-spin>
</template>
<script>
    import chat from '@/components/chat/chat'
    export default {
        components: {
          chat
        },
        data () {
          return {
              url: {
                  sendContent: "/aa/bb/add",
                  addPicture: "/aa/bb/addPicture",
                  isComplaint: "/aa/bb/isComplaint"
             }
          }
        },
        mounted() {
          this.$refs.chat.getReplyList(this.model.id)
        },
        methods: {
            //输入框按下回车发送
            handleKeydown(event) {
                if (event.shiftKey && event.keyCode === 13) {
                  document.execCommand('insertLineBreak'); // 换行
                } else if (event.keyCode === 13) { // 回车键
                  console.log("回车发送");
                  this.sendReplyContent();
                  return false;
                }
           },
           //上传图片
           uploadImg:function (){
            let that=this;
            let input = document.createElement("input");
            input.type = "file";
            input.accept = "image/gif,image/jpe
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

启东小陆

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值