UNPKG

621 BJavaScriptView Raw
1import type {
2 VUE_INSTANCE,
3 CONSTRUCTOR_OPTION
4} from './type'
5
6import getLifeCycle from './lifeCycle'
7import getRender from './render'
8import mixins from './mixins'
9
10export default class VueCompile {
11
12 constructor (option: CONSTRUCTOR_OPTION): VUE_INSTANCE {
13 return this.getInstance(option)
14 }
15
16 // 生成vue实例
17 getInstance (option: CONSTRUCTOR_OPTION): VUE_INSTANCE {
18 const render = getRender(option)
19 const data = option.data || {}
20 return Object.assign(getLifeCycle(option.lifeCycle), {
21 mixins: [mixins],
22 methods: option.method,
23 data: _ => data,
24 render
25 })
26 }
27
28}