@skax/web-components
    Preparing search index...

    @skax/web-components

    build Download Version License

    Web Components 是一套不同的技术,允许您创建可重用的定制元素(它们的功能封装在您的代码之外)并且在您的 web 应用中使用它们。

    # development
    pnpm run dev

    # production
    pnpm run build

    # build document
    # https://github.com/http-party/http-server
    # version >= 14
    pnpm run docs
    cd docs && http-server -p 8080 .

    pnpm install @skax/web-components

    wc-input, wc-button, wc-list

    <!-- script -->
    <script src="./lib/bundle/@skax/web-components.umd.js"></script>

    <form action="/get" name="form">
    <label for="name">
    <wc-input type="text" name="name" id="name" placeholder="input name"></wc-input>
    </label>
    <label for="password">
    <wc-input type="password" name="password" id="password" placeholder="input password"></wc-input>
    </label>
    <wc-button type="submit">Submit</wc-button>
    <wc-button type="rest">Rest</wc-button>
    </form>
    import '@skax/web-components';
    // import '@skax/web-components/es/button'

    function App() {
    return <wc-button>Button</wc-button>;
    }

    如果使用了 typescript,在 react-app-env.d.ts中添加下面声明。

    /// <reference types="@skax/web-components" />

    export declare global {
    namespace JSX {
    interface IntrinsicElements {
    'wc-button': WCButtonElement;
    'wc-input': WCInputElement;
    'wc-list': WCListElement;
    }
    }
    }

    example

    <script setup>
    import '@skax/web-components';
    // import '@skax/web-components/es/button'
    </script>

    <template>
    <wc-button>Button</wc-button>
    </template>

    example