omi - add extend example
This commit is contained in:
parent
926da17cce
commit
eefbad78ce
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -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>
|
|
@ -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')
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
export const extention = {}
|
||||
|
||||
export function extend(name, options) {
|
||||
extention[name] = options
|
||||
}
|
Loading…
Reference in New Issue