Skip to content

Commit

Permalink
fix: __default__ is not defined (#5)
Browse files Browse the repository at this point in the history
* Update index.ts

* 修复  export default defineComponent 跟  const XXX = defineComponent 兼容, 添加示例 C

Co-authored-by: Antes <[email protected]>
  • Loading branch information
liuye1296 and Antes authored Jul 23, 2021
1 parent 40aa7a3 commit 48871a3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
3 changes: 2 additions & 1 deletion example/App.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineComponent } from 'vue';
import A from './A';
import { B } from './B';

import C from './C'
const App = defineComponent({
data() {
return {
Expand All @@ -16,6 +16,7 @@ const App = defineComponent({
<div onClick={() => { this.a++; }}>Hello World!</div>
<A />
<B />
<C />
</>
)
}
Expand Down
18 changes: 18 additions & 0 deletions example/C.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {defineComponent, onMounted, ref} from 'vue';

export default defineComponent({
setup() {
onMounted(() => {
console.log('C')
})
const c = ref(0)
return () => (<>
<div onClick={() => {
c.value++
}}> 点我加一个
</div>
<span>我是点C 我的值是 {c.value}</span>
</>)
}
});

3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function loader(
if (t.isIdentifier(declaration)) {
if (declaredComponents.find(d => d.name === declaration.name)) {
hotComponents.push({
local: '__default__',
local: declaration.name,
id: hash(`${filename}-default`)
})
}
Expand All @@ -76,6 +76,7 @@ export default function loader(
local: '__default__',
id: hash(`${filename}-default`)
});
hasDefault = true
}
}
}
Expand Down

0 comments on commit 48871a3

Please sign in to comment.