mpvue小程序上传图片的使用和删除

# 在当前所用的template模板中嵌入html、以下代码

<div class="p10_15">
        <upload_
          :upload_info="upload_info"
          ref="uploads"
          @cb="get_choose_img"
        ></upload_>
      </div>

## 在script中引入upload组件 import upload_ from "@/components/upload"; 同样在components中国嵌入

### 在data中定义一个数组 upload_info: { class: "img50" },

#### 在methods中定义方法

  get_choose_img(res) {
      //上传的打卡照片数组
      this.upload_cb_arr = res;
      console.log(res);
    },

##### 监听页面隐藏

onHide() {
    this.$refs.uploads.$emit("clear", 1);
  },

###### 在全局中引入 css文件(放在static中)(注css可以自己手动修改一下样式)

####### 在api.config文件中添加upload: "/File/UploadFile2", //上传图片

######## 在src中的static中新建一个config.js (已上传有道云笔记)

在全局main.js中引用 const api_config = require("../static/api_config.js"); 实例化config

Vue.prototype.$api = api_config;

猜你喜欢

转载自blog.csdn.net/wei80231996/article/details/108601996