UNPKG

fezui

Version:

FEZUI 是一套基于 Vue 的支持多终端的开源UI交互组件库,致力于积木式的快速构建项目,提升产品体验和开发效率、降低开发和维护成本。

43 lines (36 loc) 1.11 kB
import LoadingBar from './loading-bar.vue'; import Vue from 'vue'; import { camelcaseToHyphen } from '../../utils/assist'; LoadingBar.newInstance = properties => { const _props = properties || {}; let props = ''; Object.keys(_props).forEach(prop => { props += ' :' + camelcaseToHyphen(prop) + '=' + prop; }); const div = document.createElement('div'); div.innerHTML = `<loading-bar${props}></loading-bar>`; document.body.appendChild(div); const loading_bar = new Vue({ el: div, data: _props, components: { LoadingBar } }).$children[0]; return { update (options) { if ('percent' in options) { loading_bar.percent = options.percent; } if (options.status) { loading_bar.status = options.status; } if ('show' in options) { loading_bar.show = options.show; } }, component: loading_bar, destroy () { document.body.removeChild(div); } }; }; export default LoadingBar;