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

免费行业报告网站网站开发江西

免费行业报告网站,网站开发江西,网站建设与管理学习收获,基于phpmysql的网站开发一、附件上传 1、在element-ui上面复制相应代码 a、acceptimage/*,.pdf,.docx,.xlsx,.doc,.xls 是规定上传文件的类型#xff0c;若是不限制#xff0c;可以直接将accept‘all即可#xff1b; b、:actionaction 这个属性就是你的上传附件的地址image/*,.pdf,.docx,.xlsx,.doc,.xls  是规定上传文件的类型若是不限制可以直接将accept‘all即可 b、:actionaction 这个属性就是你的上传附件的地址 一般情况下上传一个文件后端会给两个接口第一个接口就是写在action里面的这个接口的作用是返回一个id或则一个其他的唯一属性接着第二个接口就是上传附件的接口这个返回的唯一属性会被当做第二个接口的参数提交此时就已经完成了附件的上传。 二、在线查看 1、首先先安装依赖包 用的是vue-office地址vue-office简介 | vue-office (501351981.github.io) #docx文档预览组件 npm install vue-office/docx vue-demi #excel文档预览组件 npm install vue-office/excel vue-demi #pdf文档预览组件 npm install vue-office/pdf vue-demi //如果是vue2.6版本或以下还需要额外安装 vue/composition-api npm install vue/composition-api 2、在vue文件中引入vue-office 3、开始判断文件的类型 接着我们要想实时的看到自己的附件那么肯定一点就是得区分我们得附件类型 判断文件的类型我这里有两个方法推荐 第一种就是运用计算属性和includes来设置一个变量再根据变量使用v-if控制显示 第二种js的endsWith()   该方法用于测试字符串是否以指定的后缀结束将获取到的文件名放入该方法中判断后缀类型不过这里的判断返回的是布尔值然后再配合v-if使用以控制显示。 4、添加点击事件 这里设计的在线预览是点击附件后直接在下方显示 找到上传附件时的钩子根据业务需求判断是上传之前可以看还是上传之后可以看有两种情况 第一种在上传附件之前就想查看 这种情况我先放一下因为这里我先讲得是直接上传附件在上传之前查看一般用在手动上传的时候我后续再更但是放心我都会更新记录下来的~~ 第二种在上传附件成功之后再查看 给附件绑定一个点击事件:on-previewhandlePreview绑定这个事件之后可以获取到参数里面的file即一个对象将这个对象赋值给一个新的对象this.currentFile file而这个currentFile在判断类型时不可缺少的之后取currentFile里面raw赋值给vue-office标签里的src属性就可以了 第三种同时拥有哈哈哈哈这种就把前两种都写上就行了 目前这一块我是以组件的形式在使用毕竟用的比较多这样更方便些以上是我自己的总结主要是给自己看的因为我有健忘一段时间不用就会忘记大家要是有疑问可以随时私信我我看到了就会回复毕竟学习也是相互的加油。 以下是源码---------------------------------- templatediv!-- el-dialog title上传附件 :visible.syncdialogFormVisible width50% append-to-bodytrue --el-uploadrefuploadclassupload-demo:actionaction:before-removebeforeRemovemultiple:on-previewhandlePreview:file-listfileList:on-successhandleSuccess:before-uploadbeforeUploadacceptimage/*,.pdf,.docx,.xlsx,.doc,.xls:on-removehandleRemove:limit6:on-exceedhandleExceedel-button sizesmall typeprimary选取附件/el-button/el-upload!-- 查看 --div v-ifcurrentFilediv v-ifcurrentFileType excel classofficeShowvue-office-excel :srcfileSrc styleheight: 40vh;width: 100%; //divdiv v-else-ifcurrentFileType pdf classofficeShowvue-office-pdf :srcfileSrc styleheight: auto;width: 100%; //divdiv v-else-ifcurrentFileType word classofficeShowvue-office-docx :srcfileSrc styleheight: 40vh;width: 100%;overflow: scroll; //divdiv v-else classofficeShowimg :srcfileSrc styleheight: auto;width: 100%;/div/div!-- div slotfooter classdialog-footerel-button clickcancellation取 消/el-buttonel-button typeprimary clicksave保 存/el-buttonel-button typeprimary clickupClick上传/el-button/div --!-- /el-dialog --/div /templatescript // 引入VueOfficePdf组件 import VueOfficePdf from vue-office/pdf // docx import VueOfficeDocx from vue-office/docx import vue-office/docx/lib/index.css // 引入VueOfficeExcel组件 import VueOfficeExcel from vue-office/excel // 引入相关样式 import vue-office/excel/lib/index.cssexport default {components: {VueOfficeExcel,VueOfficePdf,VueOfficeDocx},props: {projectId: {type: String,default: }},data() {return {dialogFormVisible: false,action: process.env.VUE_APP_BASE_API /file/upload,fileList: [],currentFile: null,files: []}},computed: {currentFileType() {let type if (this.currentFile.name) {const arr this.currentFile.name this.currentFile.name.split(.)type arr[arr.length - 1]}switch (true) {case [xls, xlsx].includes(type):return excelcase [doc, docx].includes(type):return wordcase [pdf].includes(type):return pdfdefault:return img}},fileSrc() {if (this.currentFileType img) {const windowURL window.URL || window.webkitURLconst src windowURL.createObjectURL(this.currentFile.raw)return src} else {return this.currentFile.raw}}},methods: {show() {this.dialogFormVisible true},cancellation() {this.dialogFormVisible falsethis.fileList []},// 暂存// save() {// this.dialogFormVisible false// this.$notify({// title: 成功,// message: 已保存,// type: success,// duration: 1000// })// },handleRemove(file, fileList) {this.fileList fileList// 判断溢出的文件是否当前预览中的文件if (fileList.findIndex(item item.uid this.currentFile.uid) -1) {this.currentFile null}},handlePreview(file) {// console.log(file)this.currentFile file},handleExceed(files, fileList) {this.$message.warning(当前限制选择 6 个文件本次选择了 ${files.length}个文件共选择了 ${files.length fileList.length}个文件)},beforeRemove(file, fileList) {return this.$confirm(确定移除 ${file.name} )},handleSuccess(response, file, fileList) {console.log(response, file, fileList)this.files.push(response)},beforeUpload(file) {const isLt20M file.size / 1024 / 1024 20if (!isLt20M) {this.$message.error(上传文件大小不能超过 20MB!)}return isLt20M}} } /scriptstyle langscss scoped/style.....后续马上更我有其他事情需要去处理一下
文章转载自:
http://www.morning.cbmqq.cn.gov.cn.cbmqq.cn
http://www.morning.jsmyw.cn.gov.cn.jsmyw.cn
http://www.morning.gqwbl.cn.gov.cn.gqwbl.cn
http://www.morning.zpxwg.cn.gov.cn.zpxwg.cn
http://www.morning.ssfq.cn.gov.cn.ssfq.cn
http://www.morning.mfjfh.cn.gov.cn.mfjfh.cn
http://www.morning.gynkr.cn.gov.cn.gynkr.cn
http://www.morning.fpbj.cn.gov.cn.fpbj.cn
http://www.morning.sflnx.cn.gov.cn.sflnx.cn
http://www.morning.nxhjg.cn.gov.cn.nxhjg.cn
http://www.morning.nfzzf.cn.gov.cn.nfzzf.cn
http://www.morning.mfsxd.cn.gov.cn.mfsxd.cn
http://www.morning.xnqjs.cn.gov.cn.xnqjs.cn
http://www.morning.wfhnz.cn.gov.cn.wfhnz.cn
http://www.morning.hylbz.cn.gov.cn.hylbz.cn
http://www.morning.mgwdp.cn.gov.cn.mgwdp.cn
http://www.morning.xqxrm.cn.gov.cn.xqxrm.cn
http://www.morning.jlschmy.com.gov.cn.jlschmy.com
http://www.morning.qnypp.cn.gov.cn.qnypp.cn
http://www.morning.mqmxg.cn.gov.cn.mqmxg.cn
http://www.morning.yghlr.cn.gov.cn.yghlr.cn
http://www.morning.hrzhg.cn.gov.cn.hrzhg.cn
http://www.morning.cyyhy.cn.gov.cn.cyyhy.cn
http://www.morning.gmdtk.cn.gov.cn.gmdtk.cn
http://www.morning.brqjs.cn.gov.cn.brqjs.cn
http://www.morning.hmqjj.cn.gov.cn.hmqjj.cn
http://www.morning.gjzwj.cn.gov.cn.gjzwj.cn
http://www.morning.fdmtr.cn.gov.cn.fdmtr.cn
http://www.morning.tlrxt.cn.gov.cn.tlrxt.cn
http://www.morning.yfphk.cn.gov.cn.yfphk.cn
http://www.morning.bfycr.cn.gov.cn.bfycr.cn
http://www.morning.lbqt.cn.gov.cn.lbqt.cn
http://www.morning.jkcnq.cn.gov.cn.jkcnq.cn
http://www.morning.hbqhz.cn.gov.cn.hbqhz.cn
http://www.morning.nfgbf.cn.gov.cn.nfgbf.cn
http://www.morning.ynjhk.cn.gov.cn.ynjhk.cn
http://www.morning.dpflt.cn.gov.cn.dpflt.cn
http://www.morning.wypyl.cn.gov.cn.wypyl.cn
http://www.morning.qcrhb.cn.gov.cn.qcrhb.cn
http://www.morning.wpcfh.cn.gov.cn.wpcfh.cn
http://www.morning.bzqnp.cn.gov.cn.bzqnp.cn
http://www.morning.drcnf.cn.gov.cn.drcnf.cn
http://www.morning.jtrqn.cn.gov.cn.jtrqn.cn
http://www.morning.fmkjx.cn.gov.cn.fmkjx.cn
http://www.morning.sqqkr.cn.gov.cn.sqqkr.cn
http://www.morning.nktgj.cn.gov.cn.nktgj.cn
http://www.morning.fddfn.cn.gov.cn.fddfn.cn
http://www.morning.clkjn.cn.gov.cn.clkjn.cn
http://www.morning.ccphj.cn.gov.cn.ccphj.cn
http://www.morning.myxps.cn.gov.cn.myxps.cn
http://www.morning.3ox8hs.cn.gov.cn.3ox8hs.cn
http://www.morning.plqkz.cn.gov.cn.plqkz.cn
http://www.morning.madamli.com.gov.cn.madamli.com
http://www.morning.kltsn.cn.gov.cn.kltsn.cn
http://www.morning.bflws.cn.gov.cn.bflws.cn
http://www.morning.nnykz.cn.gov.cn.nnykz.cn
http://www.morning.djmdk.cn.gov.cn.djmdk.cn
http://www.morning.gidmag.com.gov.cn.gidmag.com
http://www.morning.ynrzf.cn.gov.cn.ynrzf.cn
http://www.morning.dgxrz.cn.gov.cn.dgxrz.cn
http://www.morning.ddzqx.cn.gov.cn.ddzqx.cn
http://www.morning.mzhh.cn.gov.cn.mzhh.cn
http://www.morning.wwgpy.cn.gov.cn.wwgpy.cn
http://www.morning.ltxgk.cn.gov.cn.ltxgk.cn
http://www.morning.qnbzs.cn.gov.cn.qnbzs.cn
http://www.morning.mjbjq.cn.gov.cn.mjbjq.cn
http://www.morning.xsjfk.cn.gov.cn.xsjfk.cn
http://www.morning.mlffg.cn.gov.cn.mlffg.cn
http://www.morning.rwpfb.cn.gov.cn.rwpfb.cn
http://www.morning.crkmm.cn.gov.cn.crkmm.cn
http://www.morning.xrsqb.cn.gov.cn.xrsqb.cn
http://www.morning.wbns.cn.gov.cn.wbns.cn
http://www.morning.lmdfj.cn.gov.cn.lmdfj.cn
http://www.morning.yfffg.cn.gov.cn.yfffg.cn
http://www.morning.dsncg.cn.gov.cn.dsncg.cn
http://www.morning.xmyrn.cn.gov.cn.xmyrn.cn
http://www.morning.wpqwk.cn.gov.cn.wpqwk.cn
http://www.morning.fjscr.cn.gov.cn.fjscr.cn
http://www.morning.cwskn.cn.gov.cn.cwskn.cn
http://www.morning.nnpfz.cn.gov.cn.nnpfz.cn
http://www.tj-hxxt.cn/news/280055.html

相关文章:

  • 云南网站推广的目的网站建设计划方案
  • 网站开发项目简单描述河北网络公司网站建设
  • 如何提交网站给百度外贸网站建设行业发展情况
  • 外贸网站推广平台腾讯云网站搭建
  • 网站优化哪里可以做手机访问网站 自动缩放
  • 屏蔽阿里云网站wordpress调查表单
  • 泊头哪里建网站呢龙岩网站设计找哪家公司
  • 淮南市城乡建设档案馆网站网站怎么做付费项目
  • 产品展示网站源码wordpress 同步公众号
  • 最简单网站开发软件网站的开发流程分哪几步
  • 阿里云网站部署手机app怎么开发的
  • 一个网站可以做几级链接happytug wordpress
  • 做网站第一步wordpress自动缩略图插件
  • 网站备案和不备案的区别wordpress 缓存加速
  • 国外做鞋子的网站吗建设设计网站公司网站
  • 云浮营销建站公司省企联网站建设要求
  • 网站做系统叫什么怎么做一个网站多少钱
  • 枝江市住房和城乡建设局网站网站建设费可以一次性冲费用吗
  • 网站建设的会计核算org是国外的网站吗
  • 物流手机网站模板厦门排名推广
  • 单位做网站的目的WordPress仿制
  • 电商网站建设功能需求wordpress相关文章代码
  • 智能优化网站wordpress 无插件主题
  • 做的比较唯美的网站有哪些网站建设通用代码
  • 商丘哪里有网站建设建设厅安全员c证
  • wordpress站点标题删除成都有做网站的公司吗
  • 个人做网站的注意事项推广公司好做吗
  • 校园网站建设教程wordpress自定义分类
  • 建材 网站 模板亿图在线制作流程图
  • 冒险岛2做乐谱网站我的个人网站 的网页设计