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

前端做网站需要网络营销的含义的理解

前端做网站需要,网络营销的含义的理解,重庆医院网站建设,做网上商城网站设计第076个 查看专栏目录: VUE 本文章目录 示例说明示例效果图导出的文件效果截图示例源代码参数说明:重要提示:API 参考网址 示例说明 在Vue中导出Word文档,可以使用第三方库file-saver和html-docx-js。首先需要安装这两个库: npm …

在这里插入图片描述

第076个

查看专栏目录: VUE


本文章目录

    • 示例说明
    • 示例效果图
    • 导出的文件效果截图
    • 示例源代码
    • 参数说明:
    • 重要提示:
    • API 参考网址

示例说明

在Vue中导出Word文档,可以使用第三方库file-saver和html-docx-js。首先需要安装这两个库:

npm install file-saver html-docx-js --save

然后在Vue组件中使用这两个库来导出Word文档:

示例效果图

在这里插入图片描述

导出的文件效果截图

在这里插入图片描述

示例源代码

/*
* @Author: 大剑师兰特(xiaozhuanlan),还是大剑师兰特(CSDN)
* @此源代码版权归大剑师兰特所有,可供学习或商业项目中借鉴,未经授权,不得重复地发表到博客、论坛,问答,git等公共空间或网站中。
* @Email: 2909222303@qq.com
* @weixin: gis-dajianshi
* @First published in CSDN
* @First published time: 2024-02-16
*/<template><div class="djs-box"><div class="topBox"><h3>vue导出word文档</h3><div>大剑师兰特, 还是大剑师兰特,gis-dajianshi</div><h4><el-button type="primary" size="mini" @click="exportToWord()"> 导出word文档</el-button></h4></div><div class="dajianshi" id="dajianshi"><h3> 这是我要导出的文件标题</h3><p>This is a very small library that is capable of converting HTML documents to DOCX format that is used byMicrosoft Word 2007 and onward. It manages to perform the conversion in the browser by using a featurecalled 'altchunks'. In a nutshell, it allows embedding content in a different markup language. We areusing MHT document to ship the embedded content to Word as it allows to handle images. After Word openssuch file, it converts the external content to Word Processing ML (this is how the markup language ofDOCX files is called) and replaces the reference.</p><p>Altchunks were not supported by Microsoft Word for Mac 2008 and are not supported by LibreOffice andGoogle Docs.</p></div></div>
</template><script>import FileSaver from 'file-saver';import htmlDocx from 'html-docx-js/dist/html-docx';export default {data() {return {message: 'hello world',price: 1234.56,date: '2022-01-01'}},methods: {exportToWord() {// 获取要导出的HTML内容const content = document.getElementById('dajianshi').innerHTML;// 将HTML内容转换为Word文档const converted = htmlDocx.asBlob(content);// 使用FileSaver保存Word文档FileSaver.saveAs(converted, 'example.docx');},},}
</script>
<style scoped>.djs-box {width: 1000px;height: 650px;margin: 50px auto;border: 1px solid deepskyblue;}.topBox {margin: 0 auto 0px;padding: 10px 0 20px;background: deepskyblue;color: #fff;}.dajianshi {width: 93%;height: 400px;margin: 5px auto 0;border: 1px solid #369;background-color: cde;padding: 20px;}p {font-size: 16px;text-align: left;}
</style>

参数说明:

要生成 DOCX,只需将 HTML 文档(作为字符串)传递给 asBlob 方法以接收包含输出文件的 Blob(或缓冲区)。

var converted = htmlDocx.asBlob(content);
saveAs(converted, ‘test.docx’);

asBlob 可以采用其他选项来控制文档的页面设置

orientation: landscape or portrait (default)
margins: map of margin sizes (expressed in twentieths of point, see WordprocessingML documentation for details):
top: number (default: 1440, i.e. 2.54 cm)
right: number (default: 1440)
bottom: number (default: 1440)
left: number (default: 1440)
header: number (default: 720)
footer: number (default: 720)
gutter: number (default: 0)

重要提示:

please pass a complete, valid HTML (including DOCTYPE, html and body tags). This may be less convenient, but gives you possibility of including CSS rules in style tags.

html-docx-js is distributed as ‘standalone’ Browserify module (UMD). You can require it as html-docx. If no module loader is available, it will register itself as window.htmlDocx. See test/sample.html for details.

API 参考网址

https://www.npmjs.com/package/html-docx-js

http://www.mmbaike.com/news/23235.html

相关文章:

  • 深圳建设工程造价管理站站内seo的技巧
  • 怎么制作一个最简单的网站郑州官网关键词优化公司
  • 非洲外贸网站关键词seo公司推荐
  • 篮球运动装备网站模板哪里有整站优化
  • 网站后台流程正规赚佣金的平台
  • 现在海外做的比较好一点的网站semir森马
  • 宁波网站建设论坛头条热点新闻
  • 在哪个网站可做网络夫妻培训心得简短
  • 无锡找做网站公司爱站数据官网
  • 日本做暧小视频在线观看网站宁波seo排名费用
  • 安庆网络推广和竞价优化大师班级优化大师
  • 如何不备案建网站中国十大电商公司排名
  • 思茅网站建设深圳seo优化公司排名
  • 做淘宝站外推广网站百度数据网站
  • 晚上做羞羞的事情视频网站智能营销系统开发
  • 苏州网站模板建站如何营销推广自己的产品
  • 网站建设合同付款比例app制作费用一览表
  • 百度网站排名规则手机一键优化
  • 咸阳北京网站建设重庆seo标准
  • 电子商务行业网站描述优化方法
  • 网站系统网站开发温州seo外包公司
  • 网页与网站的区别与联系注册公司网站
  • 天然气公司的网站应该怎么做平台推广销售话术
  • 在淘宝做网站可以退货退款么信息流优化师简历
  • 页面设计升级访问紧急通知济南网站优化公司哪家好
  • 制作企业网站的流程收录优美的图片
  • 做排名的网站搜索引擎seo优化怎么做
  • 有找猎聘网站做简历优化的外贸网站建设 google
  • 做网站超链接用什么软件中国军事新闻最新消息
  • 平昌网站建设谷歌优化