Skip to content

Commit

Permalink
fix: add id for stylesheet
Browse files Browse the repository at this point in the history
  • Loading branch information
chilingling committed Dec 27, 2024
1 parent cb4a0e3 commit e5189d0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/block-compiler/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const resolveRelativeImport = (code: string, globalGetterName = 'loadBlockCompon
// 声明异步组件 const Block = defineAsyncComponent(() => import(getBlockUrl(Block)))
magicStr.appendLeft(
node.start!,
`const ${defaultImportId} = defineAsyncComponent(async () => window.${globalGetterName}('${fileName}'))`
`const ${defaultImportId} = defineAsyncComponent(() => window.${globalGetterName}('${fileName}'))`
)

// 移除 import Block from './Block.vue' 语句
Expand Down
3 changes: 2 additions & 1 deletion packages/canvas/render/src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ const loadBlockComponent = async (name) => {
} else {
const newStylesheet = document.createElement('style')
newStylesheet.innerHTML = value.style
newStylesheet.setAttribute('id', fileName)
document.head.appendChild(newStylesheet)
}
}
Expand All @@ -294,7 +295,7 @@ const loadBlockComponent = async (name) => {
window.loadBlockComponent = loadBlockComponent

const getBlockComponent = (name) => {
return defineAsyncComponent(async () => loadBlockComponent(name))
return defineAsyncComponent(() => loadBlockComponent(name))
}

// 移除区块缓存
Expand Down

0 comments on commit e5189d0

Please sign in to comment.