omi - add extend example

This commit is contained in:
dntzhang 2019-08-03 18:02:57 +08:00
parent 926da17cce
commit eefbad78ce
5 changed files with 1845 additions and 0 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,11 @@
<html>
<head></head>
<body>
<script src="b.js"></script>
<my-component first="dnt" last="zhang" bool-test='aa'></my-component>
</body>
</html>

View File

@ -0,0 +1,29 @@
import { define, render, WeElement, extend } from '../../src/omi'
Omi.extend('model', {
installed(el, path) {
el.value = getValue(el, path)
el.addEventListener('change', () => {
setValue[el, path]
el.update()
})
}
})
define('my-component', class extends WeElement {
msg = 'a'
render(props) {
return (
<div>
<input v-model="msg"></input>
<div>{this.msg}</div>
</div>
)
}
})
render(<my-component />, 'body')

View File

@ -0,0 +1,5 @@
export const extention = {}
export function extend(name, options) {
extention[name] = options
}