init container
This commit is contained in:
		
							
								
								
									
										6
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,6 @@ | ||||
| node_modules | ||||
| dist | ||||
| build | ||||
| .cache | ||||
| .DS_Store | ||||
| *.log | ||||
							
								
								
									
										29
									
								
								readme.md
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								readme.md
									
									
									
									
									
								
							| @@ -1,10 +1,27 @@ | ||||
| # Container | ||||
|  | ||||
| ```js | ||||
|   const container = new Container({ | ||||
|     root: '#cid", | ||||
|     data: data, | ||||
|     showChild: false, | ||||
|   }); | ||||
|   container.renderChildren('node-1'); | ||||
| 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({ | ||||
|   root: 'root', | ||||
|   data: data, | ||||
| }); | ||||
| container.render('base-root'); | ||||
| ``` | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user