代码拉取完成,页面将自动刷新
import {computed,defineAsyncComponent,resolveComponent,unref} from 'vue'
import { isPromise } from "./compBaseUtil";
import { compGenerator } from "./compGenerator";
//
export function buildMisc(contextWrap,configStd){
//
// const component = computed(() => configStd["~component"] || configStd["~"]);
// const isFuncComp = computed(() => typeof component == "function");
//Parse component
//if it is a promise, consider it is imported as " import('xxx')"
//if it is a function,consider it as a our function component
//Otherwise consider it is a component(and try to resolve if it is a string)
const baseComponent = computed(() => {
const component = configStd.value["~component"] || configStd.value["~"];
//
if (!component) {
return "div";
}
//
if (isPromise(component)) {
return defineAsyncComponent(() => component);
} else if (typeof component == "function") {
//
return compGenerator(contextWrap, component);
} else if (typeof component == "string") {
//
return smartResolveComponent(component);
} else {
return component;
}
//
// return toRaw(component);
});
//handing possible v-if
const ifFlag = computed(() => {
const ret = configStd.value["~if"];
if (ret == undefined) {
return true;
}
//
// console.log(ret,configStd)
//
return !!unref(ret);
});
//Whether there is a v-sow setting
//true means there is a v-show setting
const hasShowFlag = computed(() => {
return configStd.value["~show"]!=undefined;
});
//handling possible v-show
const showFlag = computed(() => {
const ret = configStd.value["~show"];
if (ret == undefined) {
return true;
}
//
return !!unref(ret);
});
//Component key
const keyComp=computed(()=>{
})
//
return {baseComponent,ifFlag,hasShowFlag,showFlag}
}
//Smart resolve component, skip resolve of some name like 'div','span' to resolve veu3 warning
function smartResolveComponent(component) {
if (component == "div" || component == "span") {
return component;
}
//
return resolveComponent(component);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。