build: add vue 2.x compat package
This commit is contained in:
27
packages/vue/src/index.ts
Normal file
27
packages/vue/src/index.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { h, render, ComponentOptions } from '@vue/renderer-dom'
|
||||
|
||||
function Vue(options: ComponentOptions & { el: any }) {
|
||||
const { el, render: r } = options
|
||||
|
||||
if (r) {
|
||||
options.render = function(props, slots) {
|
||||
return r.call(this, h, props, slots)
|
||||
}
|
||||
}
|
||||
|
||||
function mount(el: any) {
|
||||
const dom = document.querySelector(el)
|
||||
render(h(options), dom)
|
||||
return (dom as any).vnode.children.$proxy
|
||||
}
|
||||
|
||||
if (el) {
|
||||
return mount(el)
|
||||
} else {
|
||||
return {
|
||||
$mount: mount
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Vue
|
||||
Reference in New Issue
Block a user