init container
This commit is contained in:
parent
e4b62ee40a
commit
eeb78110db
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
build
|
||||||
|
.cache
|
||||||
|
.DS_Store
|
||||||
|
*.log
|
23
readme.md
23
readme.md
@ -1,10 +1,27 @@
|
|||||||
# Container
|
# Container
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
import { Container } from 'https://kevisual.xiongxiao.me/system/lib/container.js';
|
||||||
|
const data = [
|
||||||
|
{
|
||||||
|
id: 'base-root',
|
||||||
|
code: {
|
||||||
|
render: (ctx) => {
|
||||||
|
const rootEl = ctx.renderRoot;
|
||||||
|
const div = document.createElement('div');
|
||||||
|
div.innerHTML = 'Hello World!';
|
||||||
|
rootEl.appendChild(div);
|
||||||
|
},
|
||||||
|
unmount: (ctx) => {
|
||||||
|
console.log('unmount');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
const container = new Container({
|
const container = new Container({
|
||||||
root: '#cid",
|
root: 'root',
|
||||||
data: data,
|
data: data,
|
||||||
showChild: false,
|
|
||||||
});
|
});
|
||||||
container.renderChildren('node-1');
|
container.render('base-root');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user