Skip to content

Commit

Permalink
fix: 🩹 修复非 KuRoot 标签下报错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
skiyee committed Jul 20, 2024
1 parent 85ed676 commit efd0c87
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ export function createApp() {
- [ ] 补全单元测试
- [ ] 使 App.vue 与正常 Vue文件一样 被使用

### 💬 社区

- QQ 交流群 ([897784703](https://qm.qq.com/q/hX1smd93MI))

### 💖 赞助

如果我的工作帮助到了您,可以请我吃包辣条,能够使我能量满满 ⚡
Expand Down
4 changes: 2 additions & 2 deletions examples/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ console.log('UniKuRoot1')
</script>

<template>
<div>123</div>
<KuRoot />
<div>这是顶部</div>
<!-- <KuRoot /> -->
<GlobalToast />
</template>
2 changes: 1 addition & 1 deletion examples/src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function handleClick() {

<template>
<view>
Hello UniKuRoot
Hello KuRoot
</view>
<button @click="handleClick">
展示Toast
Expand Down
14 changes: 8 additions & 6 deletions src/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,20 @@ export function transformCenter(ctx: ContextOptions) {
return _ms.toString()
}

if (kuRootSource) {
const parsePageSource = _appSource.replace(kuRootSource, pageNodeLoc.source)
let parsePageSource = ''

const start = pageNodeLoc.start.offset
const end = pageNodeLoc.end.offset
const start = pageNodeLoc.start.offset
const end = pageNodeLoc.end.offset

_ms.overwrite(start, end, parsePageSource)
if (kuRootSource) {
parsePageSource = _appSource.replace(kuRootSource, pageNodeLoc.source)
}
else {
_ms.append(pageNodeLoc.source)
parsePageSource = pageNodeLoc.source + _appSource
}

_ms.overwrite(start, end, parsePageSource)

return _ms.toString()
}

Expand Down

0 comments on commit efd0c87

Please sign in to comment.