snabbom安装和使用

Snabbdom 是一个虚拟DOM库,重点放在简单性,模块化,强大的功能和性能上。

1.创建目录 如: mode

2.  cnpm init -y

3. cnpm install parcel-bundler -D

4. 在更目录下新建 index.html 和 src文件夹,src 下面新建 01-main.js

5.在package.json 中配置
 

"scripts": {
    "dev":"parcel index.html  --open",
    "build":"parcel build index.html"
  },

6. 在github 网站中搜索 snabbdom

7. 安装 npm install snabbdom  

8. 在01-main.js中:
 

import {init, h}  from "snabbdom"

const patch = init([])

9.注册模块,及使用

// 1.导入模块
import{init,h,styleModule,eventListenersModule} from "snabbdom"
// 2.注册模块
const patch  = init([
  styleModule,
  eventListenersModule
])

let vnode = h("div",[
  h("h1",{style:{backgroundColor:"red"}},"yuqi"),
  h("p",{on:{click:eventClick}},"hi p")
])
function eventClick(){
  console.log("p");
}

let app = document.querySelector("#app")

patch(app,vnode)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值