/* * XmlDigitalTeaching v0.0.1 * Copyright ©Fri May 23 2025 16:54:23 GMT+0800 (中国标准时间) smile * Released under the ISC License. */ // // // // var script$1 = { name: "XmlTextRender", props: { text: { type: String, required: true, default: "默认值" } }, mounted() { console.log(this.text, "渲染的值"); } }; function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) { if (typeof shadowMode !== 'boolean') { createInjectorSSR = createInjector; createInjector = shadowMode; shadowMode = false; } // Vue.extend constructor export interop. const options = typeof script === 'function' ? script.options : script; // render functions if (template && template.render) { options.render = template.render; options.staticRenderFns = template.staticRenderFns; options._compiled = true; // functional template if (isFunctionalTemplate) { options.functional = true; } } // scopedId if (scopeId) { options._scopeId = scopeId; } let hook; if (moduleIdentifier) { // server build hook = function (context) { // 2.3 injection context = context || // cached call this.$vnode && this.$vnode.ssrContext || // stateful this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext; // functional // 2.2 with runInNewContext: true if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') { context = __VUE_SSR_CONTEXT__; } // inject component styles if (style) { style.call(this, createInjectorSSR(context)); } // register component module identifier for async chunk inference if (context && context._registeredComponents) { context._registeredComponents.add(moduleIdentifier); } }; // used by ssr in case component is cached and beforeCreate // never gets called options._ssrRegister = hook; } else if (style) { hook = shadowMode ? function (context) { style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot)); } : function (context) { style.call(this, createInjector(context)); }; } if (hook) { if (options.functional) { // register for functional component in vue file const originalRender = options.render; options.render = function renderWithStyleInjection(h, context) { hook.call(context); return originalRender(h, context); }; } else { // inject component registration as beforeCreate hook const existing = options.beforeCreate; options.beforeCreate = existing ? [].concat(existing, hook) : [hook]; } } return script; } /* script */ const __vue_script__$1 = script$1; /* template */ var __vue_render__ = function () { var _vm = this; var _h = _vm.$createElement; var _c = _vm._self._c || _h; return _c("div", { staticClass: "xml-text-box", domProps: { innerHTML: _vm._s(_vm.text) }, }) }; var __vue_staticRenderFns__ = []; __vue_render__._withStripped = true; /* style */ const __vue_inject_styles__$1 = undefined; /* scoped */ const __vue_scope_id__$1 = "data-v-38e7cca0"; /* module identifier */ const __vue_module_identifier__$1 = undefined; /* functional template */ const __vue_is_functional_template__$1 = false; /* style inject */ /* style inject SSR */ /* style inject shadow dom */ const __vue_component__$1 = /*#__PURE__*/normalizeComponent( { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ }, __vue_inject_styles__$1, __vue_script__$1, __vue_scope_id__$1, __vue_is_functional_template__$1, __vue_module_identifier__$1, false, undefined, undefined, undefined ); // var script = { name: "XmlRender", props: { data: { type: Object, default: () => ({}) } }, data() { return { component: ["", __vue_component__$1], // 组件列表 style: { "--background-color": this.data.themeColor, "--title-align": this.data.align } }; }, methods: { /** * 递归生成渲染函数 * @param {Array} data - 节点数据 * @param {number} serial - 层级序号 * @returns {Array} - 渲染结果 */ JSONTurnRender(data, serial) { console.log(data, "数据"); let children = []; // 用于收集所有子节点 for (let i = 0; i < data.length; i++) { let item = data[i]; // 优先使用 props.text 作为内容 let content = ''; if (item.props) { content = item.props.text; console.log(content, "内容"); } else { content = item.content; } // 递归生成子节点 const childNodes = item.children && item.children.length > 0 ? this.JSONTurnRender(item.children, serial + 1) : content; // 使用 props.text 或 content console.log(childNodes, "childNodes"); console.log(item.type == 0 ? item.tagName : item.props.text, "错i五"); console.log(item.tagName, "item.tagName"); // 创建当前节点的渲染结果 const xmlRender = this.$createElement( // item.type == 0 ? item.tagName : this.component[item.tagName], item.type == 0 ? item.tagName : 'div', { class: item.class, ...item.props, style: serial === 0 ? this.style : {} }, childNodes // 子节点或文本内容 ); console.log(item, "节点"); // 将当前节点的渲染结果添加到 children 数组 children.push(xmlRender); } // 返回所有子节点 console.log(children, "子节点"); return children; } }, render(h) { // 调用递归函数并返回渲染结果 console.log(this.JSONTurnRender(this.data.tagList, 0), "结果"); return h("div", this.JSONTurnRender(this.data.tagList, 0)); } // created() { // console.log(this.JSONTurnRender(this.data.tagList, 0),"看看结果"); // }, // mounted() { // console.log(this.JSONTurnRender(this.data.tagList, 0),"看看结果"); // return this.JSONTurnRender(this.data.tagList, 0); // }, }; /* script */ const __vue_script__ = script; /* template */ /* style */ const __vue_inject_styles__ = undefined; /* scoped */ const __vue_scope_id__ = "data-v-2159313a"; /* module identifier */ const __vue_module_identifier__ = undefined; /* functional template */ const __vue_is_functional_template__ = undefined; /* style inject */ /* style inject SSR */ /* style inject shadow dom */ const __vue_component__ = /*#__PURE__*/normalizeComponent( {}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, false, undefined, undefined, undefined ); let componentNamespace = 'xml'; // 组件前缀命名只能更新一次,防止重复执行修改组件注册出错 let isUpdated = false; function createNamespace(name, { prefix, isUnPrefix }) { let useNamespace; if (!isUpdated) { isUpdated = true; useNamespace = prefix || componentNamespace; // 更改前缀 } if (prefix) { if (name.indexOf(componentNamespace) === 0) { return name.replace(componentNamespace, prefix); } return useNamespace.charAt(0).toUpperCase() + useNamespace.substr(1) + name; } if (name.indexOf(componentNamespace) === 0 || name.indexOf(componentNamespace.charAt(0).toUpperCase()) === 0) { return name.charAt(0).toUpperCase() + name.substr(1); } return isUnPrefix ? name.charAt(0).toLowerCase() + name.substr(1) : componentNamespace + name.charAt(0).toUpperCase() + name.substr(1); } __vue_component__.install = (Vue, options = {}) => { Vue.component(createNamespace('render', { prefix: options.prefix }), __vue_component__); }; export { __vue_component__ as default };