vue-office/examples/dist/assets/DocxDemo-cc40b51c.js
2023-07-02 10:22:02 +08:00

2 lines
1.5 KiB
JavaScript

import{d as a}from"./docx-0c8fb292.js";import{d as l,_ as f,r as u,o as p,w as m,a as _,c as x,b as h,e as v,f as g,g as D,u as y}from"./index-893deb04.js";import{P as b,u as d}from"./PreviewWrapper-6c12c361.js";import"./_commonjs-dynamic-modules-302442b1.js";const B=l({name:"VueOfficeDocx",props:{src:[String,ArrayBuffer,Blob],requestOptions:{type:Object,default:()=>({})},options:{type:Object,default:()=>({})}},emits:["rendered","error"],setup(e,{emit:o}){const n=u(null);function c(){let t=n.value;a.getData(e.src,e.requestOptions).then(r=>{a.render(r,t,e.options).then(()=>{o("rendered")}).catch(i=>{a.render("",t,e.options),o("error",i)})}).catch(r=>{a.render("",t,e.options),o("error",r)})}return p(()=>{e.src&&c()}),m(()=>e.src,()=>{e.src?c():a.render("",n.value,e.options).then(()=>{o("rendered")})}),{rootRef:n}}}),O={class:"vue-office-docx"},$={class:"vue-office-docx-main",ref:"rootRef"};function w(e,o,n,c,t,r){return _(),x("div",O,[h("div",$,null,512)])}const s=f(B,[["render",w]]);s.install=function(e){e.component(s.name,s)};const R={__name:"DocxDemo",setup(e){function o(){d.hideLoading()}function n(t){console.log("出差",t),d.hideLoading()}const c=location.origin+(location.pathname+"/").replace("//","/")+"static/test-files/test.docx";return(t,r)=>(_(),v(b,{accept:".docx",placeholder:"请输入docx文件地址","default-src":c},{default:g(i=>[D(y(s),{src:i.src,style:{flex:"1",height:"0"},onRendered:o,onError:n},null,8,["src"])]),_:1}))}},j=f(R,[["__scopeId","data-v-4ca3fc9b"]]);export{j as default};