当前位置: 首页 > news >正文

集团企业网站建设方案策划书营销型外贸网站建设

集团企业网站建设方案策划书,营销型外贸网站建设,小米发布会8月,成都网站开发公司有哪些业务上有需求是前端上传 jpg/png/gif 格式, 并且 尺寸为 150px * 150px,300px*300px,428*428px 的图片 同时在上传的同时需要携带用户的个人信息以及其他额外信息 因此在 element-upload 基础之上 实现这个需求需要在上传前检查图片的大小,格式以及尺寸如何上传也成…

业务上有需求是前端上传 jpg/png/gif 格式, 并且 尺寸为 150px * 150px,300px*300px,428*428px 的图片

  • 同时在上传的同时需要携带用户的个人信息以及其他额外信息

因此在 element-upload 基础之上

  • 实现这个需求需要在上传前检查图片的大小,格式以及尺寸
  • 如何上传也成为一个问题
    • 使用组件的 action 上传方式, body属性传递参数
  • 限制格式,加了一句:accept=“image/jpg,image/jpeg,image/png”

1-1 展示封装的组件

1-1-1 父组件

              <uploadPic form-label="上传大图片" :before-load="beforeLargeUpload" :dialog-pic-visible="dialogPicVisible" :picture-large-dim="ruleForm.pictureLarge" :upload-data="uploadLargeData" @changePicUrl="changePicUrl" /><uploadPic form-label="上传小图片" :before-load="beforeSmallUpload" :dialog-pic-visible="dialogPicVisible" :picture-large-dim="ruleForm.pictureSmall" :upload-data="uploadLargeData" @changePicUrl="changePicUrlSmall" /><script>
data(){return{dialogPicVisible: false,}
},
methods: {// 上传图片接收参数// 大图片changePicUrl(resUrl) {this.ruleForm.pictureLarge = resUrl},// 中间图片changePicUrlMedium(resUrl) {this.ruleForm.pictureMedium = resUrl},// 小图片changePicUrlSmall(resUrl) {this.ruleForm.pictureSmall = resUrl},// 上传大图片beforeLargeUpload(file) {// const isJPG = file.type === 'image/jpeg'const isLt2M = file.size / 1024 / 1024 < 2let is80x56 = trueconst reader = new FileReader()reader.readAsDataURL(file)reader.onload = (theFile) => {const image = new Image()image.src = theFile.target.resultimage.onload = () => {const { width, height } = imageif ((width !== 482) || (height !== 482)) {this.$message.error(`图片尺寸${width}*${height},请上传482*482 px 的图片!`)is80x56 = falsereturn}}}if (!isLt2M) {this.$message.error('上传头像图片大小不能超过 2MB!')}return new Promise((resolve, reject) => {(isLt2M && is80x56).catch(err => {return err})})},// 上传中图片// 上传小图片beforeMediumUpload(file) {const isLt2M = file.size / 1024 / 1024 < 2let is300 = trueconst reader = new FileReader()reader.readAsDataURL(file)reader.onload = (theFile) => {const image = new Image()image.src = theFile.target.resultimage.onload = () => {const { width, height } = imageif (width !== 150 && height !== 150) {this.$message.error(`图片尺寸${width}*${height},请上传 300*300 px 以下的图片!`)is300 = false}}}if (!isLt2M) {this.$message.error('上传头像图片大小不能超过 2MB!')}return new Promise((resolve, reject) => {(isLt2M && is300).catch(err => {return err})})},}
</script>

1-1-2 子组件 uploadPic

<template><div><el-form-item :label="formLabel"><div style="display:flex; justify-content:space-between;"><el-input v-model="pictureLargeDim" placeholder="请点击上传按钮" :disabled="true" /><el-button type="primary" @click="dialogPicVisible = true">上传</el-button></div><el-dialog :title="formLabel" :visible.sync="dialogPicVisible"><el-uploadclass="upload-demo":limit="1"accept="image/jpeg,image/gif,image/png"dragaction="/config/upload":data="uploadData":before-upload="beforeLoad":on-success="handleAvatarSuccess":on-exceed="handleExceed"><i class="el-icon-upload" /><div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div><div slot="tip" class="el-upload__tip">只能上传jpg/png/gif文件,且不超过2MB</div></el-upload></el-dialog></el-form-item></div>
</template><script>
export default {props: {pictureLargeDim: {type: String,required: true},uploadData: {type: Object,required: true},formLabel: {type: String,required: true},// 判断是大小中图片上传beforeLoad: {type: Function,required: true}},data() {return {dialogPicVisible: false}},methods: {handleAvatarSuccess(res) {//   this.ruleForm.pictureLarge = res.urlthis.$emit('changePicUrl', res.url)this.dialogPicVisible = falsethis.$message.success('上传成功')},handleExceed() {this.$message.warning('仅上传一张图片,删除之前的图片再进行之后的操作')}}
}
</script>

1-2

参考文章:https://blog.csdn.net/qq_41800366/article/details/113309320

  • https://blog.csdn.net/qq_58340302/article/details/125939912
http://www.zhongyajixie.com/news/35085.html

相关文章:

  • 网站成功案例设计营销软文500字范文
  • 学做网站要学什么软件何鹏seo
  • 宝应网站设计留号码的广告网站不需要验证码
  • 海口专门做网站自己代理一款手游需要多少钱
  • 哈尔滨工程建设信息网官网开封网站优化公司
  • 网站建设包括什么科目全网关键词搜索工具
  • 做扎染的网站百度推广效果怎样
  • 网站运营与管理的对策建议免费关键词挖掘网站
  • 新手用什么框架做网站比较好seo服务深圳
  • 网站建设的需求分析深圳网站关键词优化推广
  • 最好的开发网站建设市场营销方案
  • 网站快照前显示中文怎么做的广州优化防控措施
  • 广告型网站建设b站视频未能成功转码
  • 仿xss网站搭建网站设计与实现毕业设计
  • 3g网站开发教程网络营销好不好
  • 框架网页模板下载seo优化排名服务
  • 家居企业网站建设平台北京seo专业团队
  • 高端网站设计百家号公关
  • 桂林手机网站建设东莞seo网络培训
  • 怎么建网站平台手机怎么建立网站
  • wordpress媒体库源码seo优化培训
  • wordpress 能承受多大并发访问量温州最好的seo
  • 新公司名字大全参考seo优化网
  • 信息设计网站优化网站的公司哪家好
  • 莘县网站建设网络推广有几种方法
  • php直播网站开发友情链接是外链吗
  • wordpress企业新闻app优化
  • wordpress多站点文章调用黑帽seo联系方式
  • 顺德做网站的公司网络营销推广公司简介
  • 有关动态网站开发技术的书包头网站建设推广