UNPKG

yuang-framework-ui-pc

Version:

yuang-framework-ui-pc Library

67 lines (66 loc) 1.56 kB
"use strict"; const vue = require("vue"); const JsBarCode = require("jsbarcode"); const props = require("./props"); const _sfc_main = vue.defineComponent({ name: "EleBarCode", props: props.barCodeProps, setup(props2) { const rootRef = vue.ref(null); const instance = vue.ref(null); const render = () => { if (!props2.value || !rootRef.value) { return; } try { instance.value = new JsBarCode( rootRef.value, props2.value, props2.options ); } catch (e) { console.error(e); } }; vue.watch( () => props2.value, () => { render(); } ); vue.watch( () => props2.options, () => { render(); }, { deep: true } ); vue.watch( () => props2.tag, () => { vue.nextTick(() => { render(); }); } ); vue.onMounted(() => { render(); }); return { rootRef, instance, render }; } }); const _export_sfc = (sfc, props2) => { const target = sfc.__vccOpts || sfc; for (const [key, val] of props2) { target[key] = val; } return target; }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.tag), { ref: "rootRef", style: vue.normalizeStyle(_ctx.value ? void 0 : { display: "none" }) }, null, 8, ["style"]); } const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]); module.exports = index;