slot demo

This commit is contained in:
dntzhang 2018-10-16 08:30:18 +08:00
parent d39e54cf05
commit 910eb536c6
5 changed files with 1063 additions and 0 deletions

1027
examples/slot/b.js Normal file

File diff suppressed because it is too large Load Diff

1
examples/slot/b.js.map Normal file

File diff suppressed because one or more lines are too long

7
examples/slot/index.html Normal file
View File

@ -0,0 +1,7 @@
<html>
<head></head>
<body>
<script src="b.js"></script>
</body>
</html>

27
examples/slot/main.js Normal file
View File

@ -0,0 +1,27 @@
import { tag, render, WeElement } from '../../src/omi'
@tag('hello-element')
class HelloElement extends WeElement {
render() {
return (
<div onClick={this.onClick}>
<p><slot name="my-text">My default text</slot></p>
</div>
)
}
}
@tag('my-app')
class MyApp extends WeElement {
render() {
return (
<div >
<hello-element>
<span slot="my-text">Let's have some different text!</span>
</hello-element>
</div>
)
}
}
render(<my-app></my-app>, 'body')

View File

@ -14,6 +14,7 @@
"copy-typescript-definition": "copyfiles -f src/omi.d.ts dist",
"build": "npm-run-all --silent clean transpile copy-flow-definition copy-typescript-definition strip optimize minify size",
"flow": "flow",
"slot": "rollup -c config/rollup.example.js --watch",
"decorators": "rollup -c config/rollup.example.js --watch",
"todo-app": "rollup -c config/rollup.example.js --watch",
"store": "rollup -c config/rollup.example.js --watch",