feat: support defining data in constructor/initialzers

This commit is contained in:
Evan You
2018-10-11 13:54:35 -04:00
parent d9e3ad72c0
commit 60e803ce62
6 changed files with 116 additions and 101 deletions

View File

@@ -18,13 +18,6 @@ interface AsyncComponentFullOptions {
type AsyncComponentOptions = AsyncComponentFactory | AsyncComponentFullOptions
interface AsyncContainerData {
comp: ComponentType | null
err: Error | null
delayed: boolean
timedOut: boolean
}
export function createAsyncComponent(
options: AsyncComponentOptions
): ComponentClass {
@@ -40,15 +33,11 @@ export function createAsyncComponent(
error: errorComp
} = options
return class AsyncContainer extends Component<{}, AsyncContainerData> {
data() {
return {
comp: null,
err: null,
delayed: false,
timedOut: false
}
}
return class AsyncContainer extends Component {
comp: ComponentType | null = null
err: Error | null = null
delayed: boolean = false
timedOut: boolean = false
// doing this in beforeMount so this is non-SSR only
beforeMount() {