build: add vue 2.x compat package

This commit is contained in:
Evan You
2018-09-19 21:52:24 -04:00
parent bc8b1678f4
commit 360ab65117
5 changed files with 70 additions and 0 deletions

27
packages/vue/src/index.ts Normal file
View 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