用于在线协议配置

页面展示

<div v-html="docHtml" />

html文本获取

function downloadDoc(url) {
    // const load = this.openInvLoading()
    let req = false
    // Safari, Firefox, 及其他非微软浏览器
    if (window.XMLHttpRequest) {
      try {
        req = new XMLHttpRequest()
      } catch (e) {
        req = false
      }
    } else if (window.ActiveXObject) {
      // For Internet Explorer on Windows
      try {
        req = new window.ActiveXObject('Msxml2.XMLHTTP')
      } catch (e) {
        try {
          req = new window.ActiveXObject('Microsoft.XMLHTTP')
        } catch (e) {
          req = false
        }
      }
    }
    const errHtml = '<p&gt;Download Error!</p&gt;'
    if (!req) {
      // load.close()
      return Promise.reject('<p class="ftm-failed"&gt;对不起,你的浏览器支持' + 'XMLHTTPRequest 对象。这个网页显示要求' + 'Internet Explorer 5 以上版本, ' + '或 Firefox 或 Safari 浏览器,也可能会有其他可兼容浏览器存在。</p&gt;')
    }
    return new Promise((resolve, reject) =&gt; {
      req.open('GET', url, true)
      req.timeout = 30000
      req.onreadystatechange = () =&gt; {
        console.log('==========(1)========&gt;>>')
        if (req.readyState === 4) {
          // load.close()
          if ((req.status >= 200 &amp;&amp; req.status < 300) || req.status === 304) {
            return resolve(req.responseText)
          }
          return reject(errHtml)
        }
      }
      req.onerror = () => {
        // load.close()
        return reject(errHtml)
      }
      req.send(null)
    })
  }
  downloadDoc('https://xxxx.html').then(docHtml => {
    console.log('==========(html)========>>>', docHtml)
  })

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注