diff --git a/src/components/TemplateCard/index.tsx b/src/components/TemplateCard/index.tsx index 6bdc6db..903ba9e 100644 --- a/src/components/TemplateCard/index.tsx +++ b/src/components/TemplateCard/index.tsx @@ -14,6 +14,7 @@ export default function TemplateCard({ template, onClick }: TemplateCardProps) { const [isDragging, setIsDragging] = useState(false) const [containerInfo, setContainerInfo] = useState(null) const containerRef = useRef(null) + const containerId = `container-${template.code}` // 为每个容器创建唯一ID const handleClick = () => { if (!isDragging) { @@ -25,7 +26,7 @@ export default function TemplateCard({ template, onClick }: TemplateCardProps) { const getContainerInfo = () => { return new Promise((resolve) => { const query = Taro.createSelectorQuery() - query.select('.merged-image-container').boundingClientRect((rect) => { + query.select(`#${containerId}`).boundingClientRect((rect) => { if (rect) { setContainerInfo(rect) resolve(rect) @@ -68,6 +69,7 @@ export default function TemplateCard({ template, onClick }: TemplateCardProps) { {/* 合成对比图片区域 */}