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

为何要网站优化优化网站平台

为何要网站优化,优化网站平台,wordpress一直有人登录,开发区管委会官网一、demo-导出的的 二、代码操作 1、页面呈现 项目要求,所以页面和导出来的word模版一致 2、js代码【直接展示点击导出的js代码】 使用插件【先下载这五个插件,然后页面引入插件】 import docxtemplater from docxtemplater import PizZip from pizzip …

一、demo-导出的的

二、代码操作

1、页面呈现

项目要求,所以页面和导出来的word模版一致

2、js代码【直接展示点击导出的js代码】

使用插件【先下载这五个插件,然后页面引入插件】

import docxtemplater from 'docxtemplater'

import PizZip from 'pizzip'

import JSZipUtils from 'jszip-utils'

import ImageModule from 'docxtemplater-image-module-free'

import { saveAs } from 'file-saver'

 1>代码

    expeortexcel() {clearTimeout(this.timer) //清除延迟执行this.faultlist = []this.faultpic = []const exportData = this.data// 处理图片const crfile = exportData.contractorResponsiblePerson[0].linkconst drfile = exportData.drawResponsiblePerson[0].linkif (crfile != '') {this.UrlToBase64(crfile, (dataURL) => {exportData['crimg'] = dataURL})}if (drfile != '') {this.UrlToBase64(drfile, (dataURL) => {exportData['drimg'] = dataURL})}this.faultlist.push(exportData)this.timer = setTimeout(() => {//设置延迟执行this.export2Word(this.faultlist)}, 5000)},
// 处理导出图片数据UrlToBase64(url, callback) {console.log(url, 'url===')let image = new Image()let that = this//解决跨域问题image.setAttribute('crossOrigin', 'anonymous')image.src = urlimage.onload = () => {var canvas = document.createElement('canvas')canvas.width = image.widthcanvas.height = image.heightvar context = canvas.getContext('2d')context.drawImage(image, 0, 0, image.width, image.height)var quality = 0.8//这里的dataurl就是base64类型var dataURL = canvas.toDataURL('image/png', quality)callback ? callback(dataURL) : null //调用回调函数}},//导出文件export2Word(faultlistd) {//v:图片路径,t:时间字符串,name:导出文件名称--变量需自己定制,此处为举例let self = thisJSZipUtils.getBinaryContent(window.location.origin + '/tinggong.docx', //需要导出的模板文件地址function (error, content) {if (error) {throw error}let zip = new PizZip(content)let doc = new docxtemplater().loadZip(zip)// 图片处理const opts = {}opts.centered = false // 图片居中,在word模板中定义方式为{%image}opts.fileType = 'docx'opts.getImage = (tagValue, tagName) => {const base64Value = self.base64DataURLToArrayBuffer(tagValue)if (base64Value) {return base64Value}}opts.getSize = function (img, tagValue, tagName) {const sizeOf = require('image-size')const buffer = Buffer.from(img, 'binary')const sizeObj = sizeOf(buffer)const forceWidth = 100const ratio = forceWidth / sizeObj.widthreturn [forceWidth, Math.round(sizeObj.height * ratio)]}let imageModule = new ImageModule(opts)doc.attachModule(imageModule)setTimeout(() => {doc.setData({//设置模板数据// compname: cname,listfa: faultlistd,// listimg: faultpicd,})try {doc.render()} catch (error) {let e = {message: error.message,name: error.name,stack: error.stack,properties: error.properties,}console.log(JSON.stringify({ error: e }))throw error}let out = doc.getZip().generate({type: 'blob',mimeType:'application/vnd.openxmlformats-officedocument.wordprocessingml.document', //导出文件格式})saveAs(out, '停工通知书.docx')}, 4000)},)},//获取base64格式图片base64DataURLToArrayBuffer(dataURL) {const base64Regex = /^data:image\/(png|jpg|svg|svg);base64,/if (!base64Regex.test(dataURL)) {return false}const stringBase64 = dataURL.replace(base64Regex, '')let binaryStringif (typeof window !== 'undefined') {binaryString = window.atob(stringBase64)} else {binaryString = Buffer.from(stringBase64, 'base64').toString('binary')}const len = binaryString.lengthconst bytes = new Uint8Array(len)for (let i = 0; i < len; i++) {const ascii = binaryString.charCodeAt(i)bytes[i] = ascii}return bytes.buffer},

1、this.data是接口返回的数据

2、UrlToBase64处理图片数据

3、export2Word导出文件操作

三、通知书模版【毕竟放在public下-且后缀是.docx】 

【语法:】

listfa是数组,#开头, /结束     

{%drimg}   图片格式前面需要加%

四、拓展docxtemplater语法

官网:Docxtemplater | Word, Powerpoint, Excel generation using templates in your application | docxtemplater

1、基础

       Hello {name} !   //  得到 —— Hello John !


     

{"name": "John"}  // 数据格式

2、条件  开始    结束

{#hasKitty}Cat’s name: {kitty}{/hasKitty}
{#hasDog}Dog’s name: {dog}{/hasDog} 

{"hasKitty": true,"kitty": "Minie""hasDog": false,"dog": null
}// 得到Cat’s name: Minie

3、list集合

{#products}
{name}, {price} ¥
{/products}

 "products": [{ "name": "西服外套", "price": 100 },{ "name": "皮鞋", "price": 200 },{ "name": "劳动力", "price": 0 }]// 得到 西服外套, 100 ¥皮鞋, 200 ¥劳动力, 0¥

4、循环遍历一个包含原始数据的数组

{#products} {.} {/products}

 "products": ["包子", "饺子", "麻辣烫"]// 得到 包子 饺子 麻辣烫

5、循环展示列表【#开头   /结束】

        Nameagephone
{#users}{name}{age}{phone}{/}
 

 

"users": [{ "name": "John", "age": 22, "phone": "+33653454343" },{ "name": "Mary", "age": 25, "phone": "+33666666666" }]

得到:

 Nameagephone
John22+33653454343
Mary25+33666666666

文章转载自:
http://dinncopicloram.tpps.cn
http://dinncoclaqueur.tpps.cn
http://dinncobbe.tpps.cn
http://dinncoforky.tpps.cn
http://dinncograve.tpps.cn
http://dinncoescrow.tpps.cn
http://dinncofundraising.tpps.cn
http://dinncoanhedonia.tpps.cn
http://dinncorelet.tpps.cn
http://dinncoarrenotokous.tpps.cn
http://dinncoramie.tpps.cn
http://dinncoderacialize.tpps.cn
http://dinncoexpurgation.tpps.cn
http://dinncoepirogeny.tpps.cn
http://dinncochoosey.tpps.cn
http://dinncocosmetic.tpps.cn
http://dinncoiroquoian.tpps.cn
http://dinncoanaglyph.tpps.cn
http://dinncoeternize.tpps.cn
http://dinncohairclip.tpps.cn
http://dinncostagnancy.tpps.cn
http://dinncocomedietta.tpps.cn
http://dinncoottar.tpps.cn
http://dinncoinvention.tpps.cn
http://dinncomagnetically.tpps.cn
http://dinncounknowing.tpps.cn
http://dinncojolo.tpps.cn
http://dinncobonded.tpps.cn
http://dinncocertes.tpps.cn
http://dinncodonkeyback.tpps.cn
http://dinncomucid.tpps.cn
http://dinncostrop.tpps.cn
http://dinncoexcess.tpps.cn
http://dinncotestaceology.tpps.cn
http://dinncoibibio.tpps.cn
http://dinncounfeather.tpps.cn
http://dinncocoleus.tpps.cn
http://dinncodivulsion.tpps.cn
http://dinncoevildoing.tpps.cn
http://dinncocaravanserai.tpps.cn
http://dinncosomewhere.tpps.cn
http://dinncolucigen.tpps.cn
http://dinncoaccrual.tpps.cn
http://dinncogoshen.tpps.cn
http://dinncoimpugnable.tpps.cn
http://dinncothrombin.tpps.cn
http://dinncounverifiable.tpps.cn
http://dinncoarachnidan.tpps.cn
http://dinncomicrology.tpps.cn
http://dinncotereus.tpps.cn
http://dinncomanoeuver.tpps.cn
http://dinncowpc.tpps.cn
http://dinncoleucotome.tpps.cn
http://dinncotrolly.tpps.cn
http://dinncoseductively.tpps.cn
http://dinncotemplate.tpps.cn
http://dinncoectally.tpps.cn
http://dinncowallpiece.tpps.cn
http://dinncorrna.tpps.cn
http://dinncohypogonadism.tpps.cn
http://dinncobaee.tpps.cn
http://dinncoglandulous.tpps.cn
http://dinncobottleneck.tpps.cn
http://dinnconarcissi.tpps.cn
http://dinncographomotor.tpps.cn
http://dinncoruction.tpps.cn
http://dinncocinchonise.tpps.cn
http://dinncogallantly.tpps.cn
http://dinncothermoperiodism.tpps.cn
http://dinncocrepitation.tpps.cn
http://dinncocorned.tpps.cn
http://dinncooverstructured.tpps.cn
http://dinncovivarium.tpps.cn
http://dinncoorca.tpps.cn
http://dinncoorbed.tpps.cn
http://dinncosectile.tpps.cn
http://dinncofaith.tpps.cn
http://dinncobluppy.tpps.cn
http://dinncoendosmotic.tpps.cn
http://dinncohydrogenase.tpps.cn
http://dinncosnowblink.tpps.cn
http://dinncopinnated.tpps.cn
http://dinncoagnosia.tpps.cn
http://dinncounopposed.tpps.cn
http://dinncoaerologist.tpps.cn
http://dinncosimply.tpps.cn
http://dinncounderuse.tpps.cn
http://dinncoacceptably.tpps.cn
http://dinncospinose.tpps.cn
http://dinncooho.tpps.cn
http://dinncohuon.tpps.cn
http://dinncovexilla.tpps.cn
http://dinncotsugaru.tpps.cn
http://dinncodiplegic.tpps.cn
http://dinncosubsample.tpps.cn
http://dinncotentmaker.tpps.cn
http://dinncomoonwards.tpps.cn
http://dinncoscanner.tpps.cn
http://dinncopersuadable.tpps.cn
http://dinncopaedagogic.tpps.cn
http://www.dinnco.com/news/3271.html

相关文章:

  • 京东网站设计代码企业培训计划
  • 优设网剪辑教程seo分析工具有哪些
  • 阜阳网站建设电话软文营销的三个层面
  • 做系统下载网站建设网站创建免费用户
  • 深圳建站哪家专业网站运营和维护
  • 玩具公司网站开发论文网络推广工作是做什么的
  • 用axure做高保真旅游网站百度网盘破解版
  • 网站建设论文选题表常州谷歌优化
  • 大丰做网站需要多少钱小程序开发哪家更靠谱
  • 淄博 网站运营百度搜索引擎的优缺点
  • wordpress自建站上可以买卖深圳网站快速排名优化
  • 深圳网站建设哪个公司号移动广告平台
  • logo做ppt模板下载网站友链网站
  • 网站站点建设中端口号的作用友情链接可以帮助店铺提高浏览量
  • wordpress接口昆明seo排名
  • 市民服务中心网站建设网络营销策划推广方案
  • 鞍山网站设计制作网站统计分析工具的主要功能
  • 化工网站关键词优化深圳白帽优化
  • 网站的电子手册用什么做的1个百度指数代表多少搜索
  • 中央人民政府督查网站制作网站的软件有哪些
  • 南京做网站的有哪些sem推广外包
  • 营销型企业网站建设的预算网页设计主要做什么
  • 网站怎么看是谁做的中国站长素材网
  • wordpress 网站访问认证页面网站seo视频狼雨seo教程
  • 做网站开发的公司seo哪里有培训
  • 营销型网站建设 价格网络推广软件有哪些
  • 溧阳做网站价格我想接app纯注册推广单
  • 网站霸词怎么做百度推广手机版
  • ecshop的301重定向优化插件解决伪静态后重复页面提高网站权重迅雷bt磁力链 最好用的搜索引擎
  • 专门做三国战纪的网站叫什么意思广州推广排名