wip(VForm): VForm component development
This commit is contained in:
parent
28be932fd2
commit
497b8fc5b4
21
src/App.vue
21
src/App.vue
|
@ -1,5 +1,5 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, ref, onMounted } from 'vue'
|
import { reactive, ref, onMounted, markRaw } from 'vue'
|
||||||
import { ElConfigProvider, ElIcon } from 'element-plus'
|
import { ElConfigProvider, ElIcon } from 'element-plus'
|
||||||
import zhCn from 'element-plus/lib/locale/lang/zh-cn'
|
import zhCn from 'element-plus/lib/locale/lang/zh-cn'
|
||||||
// import en from 'element-plus/lib/locale/lang/en'
|
// import en from 'element-plus/lib/locale/lang/en'
|
||||||
|
@ -332,8 +332,8 @@ const schema = reactive<VFormSchema[]>([
|
||||||
label: `${t('formDemo.icon')}1`,
|
label: `${t('formDemo.icon')}1`,
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
suffixIcon: Calendar,
|
suffixIcon: markRaw(Calendar),
|
||||||
prefixIcon: Calendar
|
prefixIcon: markRaw(Calendar)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -594,8 +594,8 @@ const schema = reactive<VFormSchema[]>([
|
||||||
component: 'Switch',
|
component: 'Switch',
|
||||||
value: false,
|
value: false,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
activeIcon: Check,
|
activeIcon: markRaw(Check),
|
||||||
inactiveIcon: Close
|
inactiveIcon: markRaw(Close)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -615,11 +615,18 @@ const schema = reactive<VFormSchema[]>([
|
||||||
component: 'Rate',
|
component: 'Rate',
|
||||||
value: null,
|
value: null,
|
||||||
componentProps: {
|
componentProps: {
|
||||||
voidIcon: ChatRound,
|
voidIcon: markRaw(ChatRound),
|
||||||
icons: [ChatRound, ChatLineRound, ChatDotRound]
|
icons: [markRaw(ChatRound), markRaw(ChatLineRound), markRaw(ChatDotRound)]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
if (schema[2].componentProps) {
|
||||||
|
schema[2].componentProps.placeholder = 'test'
|
||||||
|
console.log(schema[2])
|
||||||
|
}
|
||||||
|
}, 3000)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
import { unref } from 'vue'
|
import type { Slots } from 'vue'
|
||||||
import { Slots } from 'vue'
|
|
||||||
import { getSlot } from '@/utils/tsxHelper'
|
import { getSlot } from '@/utils/tsxHelper'
|
||||||
|
|
||||||
interface PlaceholderMoel {
|
interface PlaceholderMoel {
|
||||||
|
@ -76,29 +75,12 @@ export function setGridProp(col: ColProps = {}): ColProps {
|
||||||
* @returns 默认添加 clearable 属性
|
* @returns 默认添加 clearable 属性
|
||||||
*/
|
*/
|
||||||
export function setComponentProps(props: Recordable = {}): Recordable {
|
export function setComponentProps(props: Recordable = {}): Recordable {
|
||||||
const propsObj = unref(props)
|
|
||||||
// for (const key in propsObj) {
|
|
||||||
// // 如果传入的是组件,需要让其失去响应式,避免不必要的性能开销
|
|
||||||
// // 这样判断好像还不太合理。后续看看没有更合理的判断方法
|
|
||||||
// if (propsObj[key]?.render && isFunction(propsObj[key]?.render)) {
|
|
||||||
// propsObj[key] = shallowRef(propsObj[key]?.render())
|
|
||||||
// }
|
|
||||||
// // if (key === 'icon') {
|
|
||||||
// // propsObj[key] = [...propsObj[key]]
|
|
||||||
// // }
|
|
||||||
// }
|
|
||||||
const componentProps: Recordable = {
|
const componentProps: Recordable = {
|
||||||
clearable: true,
|
clearable: true,
|
||||||
...propsObj
|
...props
|
||||||
}
|
}
|
||||||
// componentProps.icons
|
|
||||||
// ? (componentProps.icons = (componentProps.icons as Recordable[]).map((v) => {
|
|
||||||
// return shallowRef(v?.render()?.value)
|
|
||||||
// }))
|
|
||||||
// : undefined
|
|
||||||
// 需要删除额外的属性
|
// 需要删除额外的属性
|
||||||
delete componentProps?.slots
|
delete componentProps?.slots
|
||||||
console.log(componentProps)
|
|
||||||
return componentProps
|
return componentProps
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue