Vue + onlyOffice

前端 Vue + onlyOffice

只是前段的基本使用

1.引入后端配置好的office服务器

 <script type="text/javascript" src="http://localhost:8081/web-apps/apps/api/documents/api.js"></script>

2.占位元素

   <div style="height: 700px;" id="table_excel">
       <div id="placeholder"></div>
   </div>

3.获取数据配置参数

具体配置请参考 ONLYOFFICE

在这里插入图片描述

       // 获取表格数据
        getExcel:function(){
            let that = this;
            this.$axios.get("接口", {}).then((res) => {
                if(res.resp_code == 200){
                    document.getElementById('table_excel').innerHTML = '<div id="placeholder"></div>';
                    var config = {
                        "editorConfig": {
                            "lang": "zh-CN",
                            "mode": res.datas.editMode, //定义编辑器打开模式。可以是查看以打开文档进行查看,也可以是编辑以在允许将更改应用于文档数据的编辑模式下打开文档。默认值为"edit"
                            "callbackUrl": "http://60.174.231.10:10001/api-forest/sOnlyOffice/docx/save?path="+res.datas.callbackUrl, // 是否显示保存按钮
                            "customization": {
                                "forcesave": res.datas.canForcesave,
                                "chat":false,
                                "comments":false,
                                "logo":{
                                    "image":that.$urlConfig.imgUrl+"/upload/logo.png",
                                    "imageEmbedded": that.$urlConfig.imgUrl+"/upload/logo.png",
                                    "url":that.$urlConfig.imgUrl+"/upload/logo.png",
                                }
                            }
                        },
                        "document": {
                            "permissions": {
                                "edit": res.datas.canEdit,  //是否可以编辑: 只能查看,传false
                                "download":res.datas.canDownload,//是否可以下载
                                "print":res.datas.canPrint //是否可以打印
                            },
                            "fileType": res.datas.fileType, // 文件类型
                            "key": res.datas.key,  //定义服务用来识别文档的唯一文档标识符
                            "title": res.datas.fileTitle, // 为查看或编辑的文档定义所需的文件名,该文件名也将在下载文档时用作文件名
                            "url": that.$urlConfig.imgUrl+"/"+res.datas.fileUrl, //定义存储查看或编辑的源文档的绝对 URL。使用本地链接时请务必添加令牌
                        },
                        "documentType": "spreadsheet",
                        "lang": "zh-CN",
                        "height": "100%",
                        "width": "100%"
                    };
                    var docEditor = new DocsAPI.DocEditor("placeholder", config);
                }else{
                    document.getElementById('table_excel').innerHTML = '';
                }
            });
        },
  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值