Skip to content

Commit 48871a3

Browse files
liuye1296Antes
andauthored
fix: __default__ is not defined (#5)
* Update index.ts * 修复 export default defineComponent 跟 const XXX = defineComponent 兼容, 添加示例 C Co-authored-by: Antes <[email protected]>
1 parent 40aa7a3 commit 48871a3

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

example/App.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defineComponent } from 'vue';
22
import A from './A';
33
import { B } from './B';
4-
4+
import C from './C'
55
const App = defineComponent({
66
data() {
77
return {
@@ -16,6 +16,7 @@ const App = defineComponent({
1616
<div onClick={() => { this.a++; }}>Hello World!</div>
1717
<A />
1818
<B />
19+
<C />
1920
</>
2021
)
2122
}

example/C.jsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {defineComponent, onMounted, ref} from 'vue';
2+
3+
export default defineComponent({
4+
setup() {
5+
onMounted(() => {
6+
console.log('C')
7+
})
8+
const c = ref(0)
9+
return () => (<>
10+
<div onClick={() => {
11+
c.value++
12+
}}> 点我加一个
13+
</div>
14+
<span>我是点C 我的值是 {c.value}</span>
15+
</>)
16+
}
17+
});
18+

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default function loader(
6767
if (t.isIdentifier(declaration)) {
6868
if (declaredComponents.find(d => d.name === declaration.name)) {
6969
hotComponents.push({
70-
local: '__default__',
70+
local: declaration.name,
7171
id: hash(`${filename}-default`)
7272
})
7373
}
@@ -76,6 +76,7 @@ export default function loader(
7676
local: '__default__',
7777
id: hash(`${filename}-default`)
7878
});
79+
hasDefault = true
7980
}
8081
}
8182
}

0 commit comments

Comments
 (0)