商城装修:修复同一类型的组件切换时,右侧属性面板不更新的问题

This commit is contained in:
owen 2023-12-07 21:18:51 +08:00
parent a7512ba2c7
commit 9ff4f1f7a9
3 changed files with 7 additions and 1 deletions

View File

@ -82,7 +82,9 @@ watch(
// //
const handleCloneComponent = (component: DiyComponent<any>) => { const handleCloneComponent = (component: DiyComponent<any>) => {
return cloneDeep(component) const instance = cloneDeep(component)
instance.uid = new Date().getTime()
return instance
} }
</script> </script>

View File

@ -111,6 +111,7 @@
view-class="p-[var(--el-card-padding)] p-b-[calc(var(--el-card-padding)+var(--el-card-padding))] property" view-class="p-[var(--el-card-padding)] p-b-[calc(var(--el-card-padding)+var(--el-card-padding))] property"
> >
<component <component
:key="selectedComponent?.uid || selectedComponent?.id"
:is="selectedComponent?.id + 'Property'" :is="selectedComponent?.id + 'Property'"
v-model="selectedComponent.property" v-model="selectedComponent.property"
/> />
@ -296,6 +297,7 @@ const handleMoveComponent = (index: number, direction: number) => {
/** 复制组件 */ /** 复制组件 */
const handleCopyComponent = (index: number) => { const handleCopyComponent = (index: number) => {
const component = cloneDeep(pageComponents.value[index]) const component = cloneDeep(pageComponents.value[index])
component.uid = new Date().getTime()
pageComponents.value.splice(index + 1, 0, component) pageComponents.value.splice(index + 1, 0, component)
} }
/** /**

View File

@ -5,6 +5,8 @@ import { TabBarProperty } from '@/components/DiyEditor/components/mobile/TabBar/
// 页面装修组件 // 页面装修组件
export interface DiyComponent<T> { export interface DiyComponent<T> {
// 用于区分同一种组件的不同实例
uid: number
// 组件唯一标识 // 组件唯一标识
id: string id: string
// 组件名称 // 组件名称