UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

72 lines (71 loc) 1.46 kB
import { defineComponent, ref, watch, nextTick, onMounted, toRefs, h } from "vue"; import _sfc_main$1 from "./echarts.mjs"; const _sfc_main = defineComponent({ name: "CoUserDefinedCollection", components: { UserEcharts: _sfc_main$1 }, props: { type: { type: String }, code: { type: String } }, setup(props) { const dom = ref(); const refresh = ref(true); watch( () => [props.type, props.code], () => { handleRefresh(); } ); const handleRefresh = () => { if (props.type && props.code) { refresh.value = true; nextTick(() => { refresh.value = false; }); } }; const RESET_VIEW = () => { if (!dom.value) return; if (props.type === "echarts") { dom.value.RESET_VIEW(); } }; onMounted(() => { handleRefresh(); }); return { dom, refresh, ...toRefs(props), RESET_VIEW }; }, render() { const getChildComponent = () => { if (this.type && this.code && !this.refresh) { return h(_sfc_main$1, { ref: "dom", code: this.code }); } return null; }; return h( "div", { class: "co-user-defined-collection", style: { width: "100%", height: "100%" } }, [getChildComponent()] ); } }); export { _sfc_main as default };