Skip to content

KillWave/future-html

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

future-html

html template

start

step 1

git clone https://github.com/KillWave/future-html.git

step 2

npm install

step 3

npm run dev

build

npm run build

exports function html render destroy

example

import { html, render,destroy } from '../src/index'
//html 字符串模板
//用法  const j =  html`<div>${变量}</div>`
//render(j,你需要添加的根元素)
//destory(你需要添加的根元素) 不需要时候释放内存
const h = (text, num,array) => html`
    <div data="${text}">123${num}
      ${html `<div>${num}</div>`}
      ${array.map(item=> {
        const div = document.createElement('div');
        div.innerHTML = item;
        return div;
      })}
    </div>
`
const root = document.querySelector('#root');

render(h('text1', 1,[5,6,7,8,9,10]  ), root)
setTimeout(() => {
  render(h('text2', 2,[1,2,3,4]), root);
  destroy(root);
}, 3000);

About

html template

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published