1.11.3 • Published 5 months ago

wkit v1.11.3

Weekly downloads
-
License
MIT
Repository
-
Last release
5 months ago

Wkit

A library for building fast, lightweight web components.

downloads version

开发文档

开发文档

我们的特色

  • @xxx=yyy 事件绑定, 可以任意节点上直接使用类似vue事件绑定的这种写法, 就可实现事件绑定。组件被移出文档时, 事件会自动销毁, 无须手动销毁。
  • @click.stop=xxx 事件绑定支持修饰符
  • :xxx=yyy, 属性绑定, 类似vue,在属性前加上:, 该属性不再使用setAttribute(), 而是直接赋值, 可满足你需要传递复杂数据结构的需求。
  • #animation={type}, 开箱即用的动画配置, 内置6种动画fade(默认), scale, bounce, micro-bounce, rotate, slide
  • ref=xxx, 类似vue的节点标识, 可方便的在mounted()之后通过 this.$refs.xxx 来访问该节点
  • 用内置的bind()方法来给当前组件绑定事件时, 组件移除时事件也会自动销毁,无需手动销毁。
  • 灵活的props定义

示例

// alias wkit='//jscdn.ink/wkit/latest/index.js'
import { css, html, Component } from 'wkit'

class Hello extends Component {

  static props = {
    count: {
      type: Number,
      default: 0,
      attribute: true // 是否显式表现为html属性
    },
    foo: 0, // 简写
    bar: String // 简写
  }

  // 若需要支持 scss语法, 则需要使用构建工具编译。
  // 可支持数组
  static styles = css`
    button { color: #09f; }
    span { color: #f30; }
  `

  // 支持多个
  static styles = [
    css`...`,
    css`...`
  ]

  render(){
    return html`
      <div>
        <button @click="${this.increase}">点击我</button>
      </div>
      <div>所有点击数为: <span>${this.count}</span></div>
    `
  }

  increase(){
    this.count++
  }

}

if (!customElements.get('wc-hello')) {
  customElements.define('wc-hello', Hello)
}
// 和上面的写法等价
// 如果不希望修改前缀`wc-`的话, 可以直接调用内置的reg方法注册组件即可。
Hello.reg('hello')


/* 

  <!-- 在html中,便可以直接使用 -->
  <wc-hello></wc-hello>

*/
1.11.3

5 months ago

1.11.2

5 months ago

1.11.1

6 months ago

1.10.13

6 months ago

1.10.14

6 months ago

1.10.11

6 months ago

1.10.12

6 months ago

1.11.0

6 months ago

1.10.5

8 months ago

1.10.4

9 months ago

1.10.3

9 months ago

1.10.2

9 months ago

1.10.9

8 months ago

1.10.8

8 months ago

1.10.7

8 months ago

1.10.6

8 months ago

1.9.7

10 months ago

1.9.6

12 months ago

1.10.10

8 months ago

1.10.1

9 months ago

1.10.0

9 months ago

0.0.0

12 months ago

1.9.5

12 months ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago