1.0.10 • Published 10 days ago

code-design-runtime v1.0.10

Weekly downloads
-
License
MIT
Repository
-
Last release
10 days ago

✨ Features

  • 🔑 Based on Web Component
  • 🏁 Reactive Web Framework
  • ⚽ Support DOM property and HTML attribute
  • ⚾ Minimum Sub-Tree Update
  • ⛄ Directives supported such as cdu-if|for|on|bind

🔨 Install

yarn add code-design-runtime
# Or with npm:
npm i code-design-runtime

🍴 Usage

Demo

<test-el id="testEl" content="something interesting"></test-el>
<script type="module">
    import CduRuntime from './dist/index.js' 
    const name = 'test-el'
    class TestEl extends CduRuntime {
        name = name    `

        commonStyleSheet = `
        span {
            font-weight: bold;
        }
    `

        styleSheet = `
        span{
            color:red;
        }
    `

        html = `
        <span cdu-on@click="this.methods.handleClick">
            {{this.prop.content}}
        </span>
        `

        propTypes = {
            props: {
                content: {
                    type: 'string',
                    description: '内容'
                }
            },
            events: {
                click: {
                    name: 'click-event',
                    description: '点击事件'
                }
            }
        }

        methods = {
            handleClick: (event) => {
                this.emitEvent(event, this.propTypes.events.click.name)
            },
        }
    }
    window.customElements.define(name, TestEl)
    window.onload = () => {
        const el = document.querySelector('#testEl')
        el.addEventListener('click-event', (event) => {
            console.log(event)
        })
    }
</script>

Directives Supported

  • {{ xxx }} 或 cdu-bind:textContent="xxx" 例:{{ this.state.name + this.prop.code + this.inherit.item.label}} 、 {{ this.format.call(this, this.state.name, this.state.code) }}
  • cdu-on@click="xxx" 例: this.handleClick、this.handleClick.bind(this, this.state.showList)
  • cdu-if="xxx" -> 例: this.state.name && this.prop.code && this.inherit.item.label、this.validate.call(this,this.state.list)
  • cdu-for="xxx" -> 例:item in this.state.list/this.props.list/this.getList.call(this, this.state.name)

📞 Contact With Me

Email: yxlolxy@qq.com

1.0.10

10 days ago

1.0.9

1 month ago

1.0.8

1 month ago

1.0.7

1 month ago

1.0.6

1 month ago

1.0.5

1 month ago

1.0.4

1 month ago

1.0.3

1 month ago

1.0.2

1 month ago

1.0.1

2 months ago

1.0.0

2 months ago