举例word.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="http://XXX自己服务器下的地址XXXX/web-apps/apps/api/documents/api.js"></script>
</style>
</head>
<body style="height: 100vh;">
<div id="placeholder" style="height: 100%; width: 100%;"></div>
<script language="javascript" type="text/javascript">
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
return (false);
}
// alert(getQueryVariable('url'));
new DocsAPI.DocEditor("placeholder", {
"document": {
"fileType": "docx",
//"key": "12NAFE",
"title": "预览.docx",
// "url": "http://xxxxxxxxx.xls"
"url": getQueryVariable('url'),
},
"documentType": "text",
"width": "100%",
"height": "100%",
"editorConfig": {
"lang":"zh-CN",
// "callbackUrl": "编辑word后保存时回调的地址,这个api需要自己写了,将编辑后的文件通过这个api保存到自己想要的位置"
},
"permissions": {
"comment": true,
"download": true,
"edit": true,
"fillForms": true,
"print": true,
"review": true
}
});
</script>
</body>
</html>
最重要的是服务器下的地址,后端人员也需要配合启动应用才能使用
<script type="text/javascript" src="http://XXX自己服务器下的地址XXXX/web-apps/apps/api/documents/api.js"></script>
</style>
还有根据不同的格式属性值不同
"document": {
"fileType": "docx",
.......
},
"documentType": "text",
这是官网的属性值
![](https://img.haomeiwen.com/i18112037/a836a6a2764315e6.png)
企业微信截图_16709866076042.png
网友评论