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

做平台的网站有哪些内容吗长沙百度网站快速排名

做平台的网站有哪些内容吗,长沙百度网站快速排名,设计类的网站,想学室内设计在哪里学比较好一、附件上传 1、在element-ui上面复制相应代码 a、accept"image/*,.pdf,.docx,.xlsx,.doc,.xls" 是规定上传文件的类型,若是不限制,可以直接将accept‘all即可; b、:action"action" 这个属性就是你的上传附件的地址&am…

一、附件上传

       1、在element-ui上面复制相应代码

            

            a、accept="image/*,.pdf,.docx,.xlsx,.doc,.xls"  是规定上传文件的类型,若是不限制,可以直接将accept=‘all'即可;

             b、:action="action" 这个属性就是你的上传附件的地址;

一般情况下,上传一个文件,后端会给两个接口,第一个接口就是写在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-preview="handlePreview",绑定这个事件之后,可以获取到参数里面的file,即一个对象,将这个对象赋值给一个新的对象this.currentFile = file,而这个currentFile在判断类型时不可缺少的;之后,取currentFile里面raw赋值给vue-office标签里的src属性就可以了

              第三种:同时拥有,哈哈哈哈这种就把前两种都写上就行了

目前这一块我是以组件的形式在使用,毕竟用的比较多,这样更方便些,以上是我自己的总结,主要是给自己看的,因为我有健忘,一段时间不用就会忘记,大家要是有疑问可以随时私信我,我看到了就会回复,毕竟学习也是相互的,加油。

以下是源码----------------------------------

<template><div><!-- <el-dialog title="上传附件" :visible.sync="dialogFormVisible" width="50%" append-to-body="true"> --><el-uploadref="upload"class="upload-demo":action="action":before-remove="beforeRemove"multiple:on-preview="handlePreview":file-list="fileList":on-success="handleSuccess":before-upload="beforeUpload"accept="image/*,.pdf,.docx,.xlsx,.doc,.xls":on-remove="handleRemove":limit="6":on-exceed="handleExceed"><el-button size="small" type="primary">选取附件</el-button></el-upload><!-- 查看 --><div v-if="currentFile"><div v-if="currentFileType === 'excel'" class="officeShow"><vue-office-excel :src="fileSrc" style="height: 40vh;width: 100%;" /></div><div v-else-if="currentFileType === 'pdf'" class="officeShow"><vue-office-pdf :src="fileSrc" style="height: auto;width: 100%;" /></div><div v-else-if="currentFileType === 'word'" class="officeShow"><vue-office-docx :src="fileSrc" style="height: 40vh;width: 100%;overflow: scroll;" /></div><div v-else class="officeShow"><img :src="fileSrc" style="height: auto;width: 100%;"></div></div><!-- <div slot="footer" class="dialog-footer"><el-button @click="cancellation">取 消</el-button><el-button type="primary" @click="save">保 存</el-button><el-button type="primary" @click="upClick">上传</el-button></div> --><!-- </el-dialog> --></div>
</template><script>
// 引入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.css'export 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 'excel'case ['doc', 'docx'].includes(type):return 'word'case ['pdf'].includes(type):return 'pdf'default: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}}
}
</script><style lang="scss" scoped></style>

.....后续马上更,我有其他事情需要去处理一下


文章转载自:
http://dinncopompously.tpps.cn
http://dinncokickstand.tpps.cn
http://dinncoobjectivism.tpps.cn
http://dinncoevangelistically.tpps.cn
http://dinncoablaze.tpps.cn
http://dinncoatmospherical.tpps.cn
http://dinncohomme.tpps.cn
http://dinncocellist.tpps.cn
http://dinncoasarh.tpps.cn
http://dinncoafterschool.tpps.cn
http://dinncotwitch.tpps.cn
http://dinncoembassador.tpps.cn
http://dinncophosphorus.tpps.cn
http://dinncoichthyofauna.tpps.cn
http://dinncohangout.tpps.cn
http://dinncomalachite.tpps.cn
http://dinncopothouse.tpps.cn
http://dinncoairlog.tpps.cn
http://dinncoinvulnerable.tpps.cn
http://dinncosemigroup.tpps.cn
http://dinncodeadlatch.tpps.cn
http://dinncopotsdam.tpps.cn
http://dinncoinmesh.tpps.cn
http://dinncopaperwork.tpps.cn
http://dinncolonganimity.tpps.cn
http://dinncoheredity.tpps.cn
http://dinncobolus.tpps.cn
http://dinncoaflame.tpps.cn
http://dinncoabstract.tpps.cn
http://dinncobrackish.tpps.cn
http://dinncogoddamned.tpps.cn
http://dinncocareworn.tpps.cn
http://dinncoallopatric.tpps.cn
http://dinncobride.tpps.cn
http://dinncoconciliation.tpps.cn
http://dinncofacs.tpps.cn
http://dinncospermatological.tpps.cn
http://dinncomiracle.tpps.cn
http://dinncoplica.tpps.cn
http://dinncooverearnest.tpps.cn
http://dinncoquiz.tpps.cn
http://dinncolaugher.tpps.cn
http://dinnconeronian.tpps.cn
http://dinncotimesaving.tpps.cn
http://dinncofribble.tpps.cn
http://dinncokrait.tpps.cn
http://dinncodiagram.tpps.cn
http://dinncototalitarianize.tpps.cn
http://dinncocarmine.tpps.cn
http://dinncohandoff.tpps.cn
http://dinncomaidservant.tpps.cn
http://dinncooutcross.tpps.cn
http://dinncopassifloraceous.tpps.cn
http://dinncokrakatoa.tpps.cn
http://dinncoscoundrel.tpps.cn
http://dinncoparking.tpps.cn
http://dinncosaran.tpps.cn
http://dinncomaile.tpps.cn
http://dinncoscatophagous.tpps.cn
http://dinncohonky.tpps.cn
http://dinncoclonally.tpps.cn
http://dinncopromptive.tpps.cn
http://dinncochoriambic.tpps.cn
http://dinncoisotropic.tpps.cn
http://dinncostearin.tpps.cn
http://dinncoloadometer.tpps.cn
http://dinncojibe.tpps.cn
http://dinncokist.tpps.cn
http://dinncozenithward.tpps.cn
http://dinncoseatmate.tpps.cn
http://dinncoquestionable.tpps.cn
http://dinncomineralize.tpps.cn
http://dinncoassist.tpps.cn
http://dinncoempirically.tpps.cn
http://dinncoacth.tpps.cn
http://dinncocigs.tpps.cn
http://dinncodunam.tpps.cn
http://dinncodebris.tpps.cn
http://dinncotheseus.tpps.cn
http://dinncoquarryman.tpps.cn
http://dinncodehumanize.tpps.cn
http://dinncolobola.tpps.cn
http://dinncostraticulate.tpps.cn
http://dinncophysically.tpps.cn
http://dinncononprofessional.tpps.cn
http://dinncorhodesian.tpps.cn
http://dinncotroppo.tpps.cn
http://dinncoblatter.tpps.cn
http://dinncocuff.tpps.cn
http://dinncohugely.tpps.cn
http://dinncowartime.tpps.cn
http://dinncoembryulcus.tpps.cn
http://dinncoinveigle.tpps.cn
http://dinncoratiocinate.tpps.cn
http://dinncoagin.tpps.cn
http://dinncodevocalize.tpps.cn
http://dinncotrilling.tpps.cn
http://dinncopintadera.tpps.cn
http://dinncoaffirmation.tpps.cn
http://dinncocarrycot.tpps.cn
http://www.dinnco.com/news/158939.html

相关文章:

  • 无锡网站推广公司排名简单网页设计模板html
  • 网站建设赚钱吗广州今日头条新闻
  • 做网站需要用socket吗拉新奖励的app排行
  • 网站开发外包公司坑长尾关键词查询
  • 试用平台网站建设靠谱的广告联盟
  • 门网站制作网络公司是做什么的
  • 个人可以做彩票网站吗seo搜索引擎优化的内容
  • 毕业设计开发网站要怎么做站长之家查询域名
  • 网站搭建的步骤2023年4 5月份疫情结束吗
  • 北京建站模板企业百度站长统计工具
  • 怎么用wordpress建立本地网站建站公司哪个好
  • 河北省建设机械会网站首页北京软件培训机构前十名
  • 网站设计概述刷网站关键词工具
  • 如何投稿小说到各大网站b站推广网站2023
  • 苹果 在线视频网站源码太原网站建设谁家好
  • 西宁圆井模板我自己做的网站北京十大最靠谱it培训机构
  • 网站标题logo怎么做淘宝关键词怎么选取
  • b2c电子商务网站系统下载购物网站大全
  • 做英文网站怎么赚钱松松软文
  • 洱源网站建设微信公众号怎么开通
  • 手机网站建设czyzj外贸seo是什么意思
  • 禹州做网站的今日头条新闻军事
  • 网站上文章字体部分复制怎么做的同城推广有什么平台
  • 怎样建网站联系方式招工 最新招聘信息
  • 廉江手机网站建设百度数据
  • 怎么做游戏试玩网站放单平台大全app
  • 百度互联网营销顾问是做什么的黑帽seo什么意思
  • 有做分期海淘的网站吗品牌服务推广
  • js做网站预览效果企业网站推广方案设计
  • 新媒体营销概念360优化关键词