实用的API
2021-08-07 by uino 0 资源工厂

window.Subscribe.subscribe

Subscribe 为产品内数据监测API;

Subscribe订阅API里的原型是这样的 subscribe(url, time, fn, params, key) {}

里边五个参数的意思分别为:

url 接口地址;

time 刷新频率 ms,默认一分钟;

fn 执行函数;

params 接口参数;

key 图表数据标识;

window.Subscribe.subscribe使用实例如下

initMounted() {
    if (this.interfaceAddr) {
        window.Subscribe.subscribe(this.interfaceAddr, this.updateFrequency, this.getData, this.params, this.interfaceKey);
    }
},

window.Subscribe.unSubscribe

window.Subscribe.unSubscribe为取消订阅,使用实例如下

destroyed() {
    window.Subscribe.unSubscribe(this.interfaceAddr, this.updateFrequency, this.params, this.interfaceKey);
},

uinv.util.getResourceUrl

使用图片或引入js文件时取绝对路径,获取当前资源的绝对路径,实例如下图所示:

// 加载js文件
createJascript() {
    const js = document.createElement('script');
    js.setAttribute('id', 'soho');
    const url = uinv.utils.getResourceUrl('configure/business/chart/component-chartWaterLevel/echarts-liquidfill.min.js');
    js.src = url;
    document.head.appendChild(js);
},