add default render tmpl & scope to json display (#10124)

This commit is contained in:
Azri Kahar
2021-12-02 03:05:48 +08:00
committed by GitHub
parent 2fa2a75b60
commit 8d68374bbd

View File

@@ -46,15 +46,23 @@ export default defineComponent({
try {
if (Array.isArray(props.value)) {
return props.value.map((item: any) => render(props.format || '', item));
return props.value.map((item: any) => renderValue(item));
} else {
return [render(props.format || '', props.value)];
return [renderValue(props.value)];
}
} catch {
return null;
}
});
function renderValue(input: Record<string, any> | Record<string, any>[]) {
if (props.format) {
return render(props.format, input);
} else {
return render('{{ value }}', { value: input });
}
}
return { displayValue, t };
},
});