新的2.0.2版解决一个页面上,需要加载多个文档实例的场景,如何使用这个功能

阅读次数 57

新的版本可以同一网页加载多个文档,具体用法有介绍吗?

2 Answers

iframe嵌套能否实现你的需求?

当然可以,就是嵌套层多,iframe间通讯也不方便。

你好v2.0.2是可以支持多实例的。


示例参考:

const startup = async (opts = {}) => {
        const token = 'xxx'
        const instance = WebOfficeSDK.init({
          appId:'xxx',
          token,
          ...opts
        })

        instance.on('fileOpen', data => {
          console.log('fileOpen', data)
        })

        await instance.ready()

        return Promise.resolve(instance) 
      }

      window.onload = async function() {
        const p1 = startup({
          mount: '#app1',
          fileId:'xxx',
          officeType: 'p',
        })
        const p2 = startup({
          mount: '#app2',
          fileId: 'xxx',
          officeType: 'w',
        })
        const [pptInstance, wordInstance] = await Promise.all([p1, p2])
      }