Socket
Book a DemoInstallSign in
Socket

@bd/core

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bd/core

百搭UI组件库的核心

1.9.5
latest
Source
npmnpm
Version published
Maintainers
2
Created
Source

百搭UI组件库的核心

开发文档

开发文档

我们的特色

  • @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定义

示例

import { css, html, Component } from '//jscdn.ink/@bd/core/latest/index.js'

class Hello extends Component {

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

  // 若需要支持 scss, 则需要使用 @bd/wcui-cli,预处理。
  // 可支持数组
  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>

*/

Keywords

bd.js

FAQs

Package last updated on 08 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.