最近自己在研究vue,然后做了一个小型的后台管理系统用来练手,开发过程中,想到了剪切图片上传用户头像的需求.上网百度了一番,发现好多用的都是vue-cropper.我也就用了,个人感觉还是挺好用的.现在在这里用一个简单的小demo演示一下vue-cropper的使用方法. 其中上传用户头像的接口是java写的,感兴趣的话可以参考我的2017年12月2号的博客:前后端分离跨服务器文件上传-Java SpringMVC版 1.安装vue-cropper 使用npm本地安装vue-cropper np…
图片剪裁上传插件 - cropper <style> .photo-container{float: left;width: 300px;height: 300px;} .photo-container { padding-left: 10px; box-sizing: border-box; } .photo-container li{line-height: 20px;} .photo-container .photo-preview{margin-top: 10px;overflow:…
项目使用VUE编写,UI是ElementUI,但是Element的Upload组件是不兼容IE9的.因为IE9中无法使用FormData. 查找资料基本有两种解决方法:1.引入JQuery和jQuery.form.2.使用vue-upload-component 1.jQuery.form 插件提供ajaxSubmit和ajaxForm两种表单提交方式,注意:不要对同一个表单同时使用两种方式. ajaxSubmit是jQuery表单插件核心函数.非常灵活,因为它依赖于事件机制,只要有事件触发就能…
一.引入文件 <script src="jquery.min.js"></script> <link rel="stylesheet" href="cropper.css"> <script src="cropper.js"></script> 二.html代码 <div class="box"> <img id="im…
目录 1 UI库使用ElementUI 2 后端使用Express + formidable模块 1 UI库使用ElementUI 安装ElementUI $ npm install --save-dev element-ui vue加载ElementUI import ElementUI from 'element-ui' // 导入elementui库 import 'element-ui/lib/theme-chalk/index.css' // 导入样式 Vue.use(ElementU…
this.compress(result, 800, 0.5).then(val => { //得到压缩图片 let data = val; that.file = that.dataURLtoFile(data, that.file_name); //上传 that.upload(); }); // 压缩图片 compress(base64String, w, quality) { // var getMimeType = function(urlData) { // var arr = ur…
//单图上传 <template> <div> <div class="uploader" v-if='!dwimg'> <van-uploader :after-read="ondwRead" accept="image/gif, image/jpeg" multiple> <van-icon name="photograph" /> </van-upload…
<template> <label for="file" class=" btn btn-default" style="border:1px solid red">多文件上传</label> <input type="file" style="display:none;" id="file" multiple @change="fil…
不多说直接上代码: 前台代码: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <link href="../layui/layui/css/layui.css" rel="stylesheet" /> <link href="../layui/cropp…
下面代码直接就可以复制使用了,但是需要在本地下个cropperjs,下载命令:npm install cropperjs --save-dev <template> <div id="yin"> <div id="demo"> <!-- 遮罩层 --> <div class="container" v-show="panel"> <div> <img…