import Vue from "vue";
import App from "./App.vue";
import "./registerServiceWorker";
import router from "./router";
import store from "./store";
import "amfe-flexible";
// 全局引入Echarts;
import * as echarts from "echarts";
// 然后挂载在vue原型上;
import "echarts-gl";
Vue.prototype.$echarts = echarts;
Vue.config.productionTip = false;
// echarts 页面适配    ====↓↓↓↓↓↓↓↓↓↓========
// 定义全局指令
Vue.directive('resize', { // 使用局部注册指令的方式
  // 指令的名称
  bind(el, binding) { // el为绑定的元素，binding为绑定给指令的对象
    let width = '',
      height = '';

    function isReize() {
      const style = document.defaultView.getComputedStyle(el);
      if (width !== style.width || height !== style.height) {
        binding.value(); // 关键
      }
      width = style.width;
      height = style.height;
    }
    el.__vueSetInterval__ = setInterval(isReize, 300);
  },
  unbind(el) {
    clearInterval(el.__vueSetInterval__);
  }

})
new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
