0.1.8 • Published 5 years ago

iwen-pic-upload v0.1.8

Weekly downloads
4
License
-
Repository
github
Last release
5 years ago

iwen-image-upload

基于vue、element的上传图片组件

依赖项

vue 、element ui

安装

$ npm i iwen-image-upload --save-dev

使用

需全局注入element ui

// src/main.js
import Vue from "vue";
import App from "./App.vue";
import "element-ui/lib/theme-chalk/index.css";
import ElementUI from "element-ui";
Vue.use(ElementUI);
//demo.vue

<template>
  <div id="app">
    <iwen-image-upload class="image-upload" :action="action" isCropper v-model="imgUrl" />
  </div>
</template>

<script>
import iwenImageUpload from "iwen-image-upload";

export default {
  name: "app",
  components: {
    iwenImageUpload
  },
  data() {
    return {
      imgUrl: "",
      action: "/api/file/uploadImg"
    };
  }
};
</script>

<style>
#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
.image-upload {
  margin: 0 auto;
  width: 200px;
}
</style>

属性(Props)

参数说明类型可选值默认值
value / v-mode绑定值string
allowDelete是否允许删除图片booleanfalse
imgWidth上传组件和图片展示的宽度string--100px
imgHeight上传组件和图片展示的高度string--100px
tip组件下方的灰色字提示string----
name原生上传 inputfile name值string----
uploadKey上传的formData对应的key值string--file
round是否展示圆形图片boolean--false
autoCropHeight裁剪高度string--100px
autoCropWidth裁剪宽度string--100px
maxSize上传图片限制的大小,以M为单位number--8
isCropper是否裁剪boolean--false
action上传的urlstring----
resUrlKey返回的res.data下面url的keystring--url

事件(Events)

事件名称说明回调参数
upload-success上传成功res.data和name
cropper-success裁剪成功Blob值
on-remove删除成功name值
upload-failure上传失败name值

方法

方法名说明参数
clearValue清楚input 的值--