1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        PreactReact 的輕量化替代方案

        聯(lián)合創(chuàng)作 · 2023-09-19 10:49

        Preact 是 React 的輕量化替代方案,僅有 3KB。并且提供了相同的 ES6 API,還具有組件和 Virtual DOM。

        具有以下特性:

        • 更接近于實質(zhì):Preact 在 DOM 上實現(xiàn)一個可能是最薄的一層虛擬 DOM 實現(xiàn)。

        • 小體積:這將意味可以下載更少的 JavaScript 代碼,解析和執(zhí)行 —— 為您的代碼節(jié)省更多的時間。

        • 高性能:不僅是因為他的體積,還因為一個簡單和可預(yù)測的 diff 實現(xiàn),使它成為最快的虛擬 DOM 框架之一。

        • 輕量 & 可嵌入:使用 Preact 構(gòu)建應(yīng)用程序的各個部分,而無需復(fù)雜的集成。將 Preact 嵌入到窗口小部件中并應(yīng)用相同的工具或技術(shù),你將可以構(gòu)建一個完整的應(yīng)用程序。

        • 生態(tài)系統(tǒng)兼容:可以無縫使用 React 生態(tài)系統(tǒng)中可用的數(shù)千個組件。

        示例代碼:

        獲取 Github Stars

        export default class Stars extends Component {
            async componentDidMount() {
                let stars = await githubStars(this.props.repo);
                this.setState({ stars });
            }
            render({ repo }, { stars=0 }) {
                let url = `//github.com/${repo}`;
                return (
                    <a href={url} class="stars">
                        ?? {stars} Stars
                    </a>
                );
            }
        }

        運行例子

        import Stars from './stars';
        render(
            <Stars repo="developit/preact" />,
            document.body
        );
        瀏覽 26
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        編輯 分享
        舉報
        評論
        圖片
        表情
        推薦
        點贊
        評論
        收藏
        分享

        手機掃一掃分享

        編輯 分享
        舉報
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            翔田千里中文字幕手机免费观看 | 手机在线看a | 上原瑞穗av无删减版 | 一级在线观看 | 九色porny丨精品自拍视频 | 黄色小说免费看 | 亚洲欧美精品国产 | chinese勾搭少妇vid | 秘书与老板办公室做爰电影 | 又黄又爽在线观看 |