export default {
  init: function () {
    console.log('引入低版本的echarts和gl...')
    // eslint-disable-next-line camelcase
    const echarts_URL = 'https://fastly.jsdelivr.net/npm/echarts@4.2.1/dist/echarts.min.js'
    return new Promise((resolve, reject) => {
      // 如果已加载直接返回
      if (typeof echarts !== 'undefined') {
        // eslint-disable-next-line no-undef
        resolve(echarts)
        return true
      }

      // 插入script脚本
      let scriptNode = document.createElement('script')
      scriptNode.setAttribute('type', 'text/javascript')
      scriptNode.async = true
      scriptNode.setAttribute('src', echarts_URL)
      document.body.appendChild(scriptNode)
      scriptNode.onload = function () {
        debugger
      }
    })
  }
}
