鎯冲啓 JSX锛屽張涓嶆兂鐢ㄧ紪璇戝櫒锛烪TM 鍙互甯綘
Posted UC鍥介檯鎶€鏈?/a> 鎯
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了鎯冲啓 JSX锛屽張涓嶆兂鐢ㄧ紪璇戝櫒锛烪TM 鍙互甯綘相关的知识,希望对你有一定的参考价值。
璇戣€咃細UC 鍥介檯鐮斿彂 Jothy
HTM 鏄函 javascript 瀹炵幇鐨勭被 JSX 鐨勮娉?- 鏃犻渶杞崲鍣?/strong>灏卞彲浠ヤ娇鐢ㄣ€?/h1>
浣犲彲鐩存帴浣跨敤 React/Preact 鍦ㄦ祻瑙堝櫒涓紑鍙戯紝鐒跺悗灏?HTM 缂栬瘧涓虹敓浜у寘銆傚畠浣跨敤鏍囧噯 JavaScript 鏍囩妯℃澘锛岄€傜敤浜庢墍鏈夌幇浠f祻瑙堝櫒銆?/h1>
HTM 鐨勫悇椤规暟鎹?/span>
馃悾 鐩存帴鍦ㄦ祻瑙堝櫒涓娇鐢ㄦ椂 < 700 bytes
鈿涳笍 涓?Preact 涓€璧蜂娇鐢ㄦ椂 < 500 bytes锛堟劅璋?gzip 馃寛锛?/span>
馃弲浣跨敤 babel-plugin-htm 缂栬瘧鏃?0 bytes
璇硶锛氱被 JSX锛屼絾鏈夋墍鎻愬崌
浣跨敤 HTM 缂栧啓鐨勮娉曟棤闄愭帴杩?JSX 鈾撅細
Spread props锛?/span><div ...${props}>
鑷叧闂爣绛撅細<div />
缁勪欢锛?<${Foo}>
锛堝叾涓?Foo
鏄粍浠跺紩鐢級
甯冨皵灞炴€э細<div draggable />
瀵?JSX 鐨勬敼杩?/span>
瀹為檯涓?HTM 鏇存繁搴﹂噰鐢ㄤ簡 JSX 椋庢牸鐨勮娉曪紒
浠ヤ笅鏄?JSX 涓笉鍏峰鐨勭鍚堜汉浣撳伐绋嬪鐨勫姛鑳斤細
鏃犻渶缂栬瘧鍣?/span>
html 寮曞彿鍙€夛細<div class=foo>
缁勪欢缁撴潫鏍囪锛?<${Footer}>footer content<//>
閫氳繃 lit-html VSCode 鎻掍欢瀹炵幇璇硶楂樹寒鍜岃瑷€鏀寔
馃帀 HTM 2.0 鍙戝竷鍟︼紒
鎴戜滑浣跨敤鍏ㄦ柊鐨勮嚜瀹氫箟 JSX 瑙f瀽鍣紝浠庡ご寮€濮嬫瀯寤?HTM 鐨勬€ц兘鍜屽ぇ灏忋€?/span>
杩欏浣犳潵璇存剰鍛崇潃浠€涔堬紵
HTM 閫熷害鎻愬崌浜?20 鍊?/span> 馃殌
鈥︿綋绉缉灏忎簡 10锛?/span>
鈥﹂殢澶勮繍琛岋紙鍘熺敓 SSR锛侊級
璇硶鏃犻檺鎺ヨ繎 JSX
缂撳瓨閫熷害鎻愰珮20锛?/span>
鏇翠紭鐨勮緭鍑?/span>
鍏ㄦ柊鐨?Babel 鎻掍欢锛?/span>
鎴戜滑鐨?Babel 鎻掍欢涔熻繘琛屼簡澶у箙淇敼锛?瀹冪殑閫熷害鎻愰珮浜?1-2 涓噺绾э紝涓嶅啀闇€瑕?JSDOM锛屽苟涓旀敮鎸佽嚜瀹氫箟杈撳嚭銆?/span>
姝ゆ洿鏂拌繕淇浜嗙紦瀛樸€佽竟缂樻儏鍐靛拰绌虹櫧澶勭悊鐩稿叧鐨勫涓棶棰樸€?/span>
杩樺甫鏉ヤ簡鏂拌娉曪紵
鏄殑锛屼絾鍒厡銆?鐜板湪鍐?HTM 鍩烘湰涓婂氨鏄湪鍐?JSX銆?/span>浣犲彧闇€瑕佽浣忎袱浠朵簨锛?/span>
<Foo>
涔嬬被鐨勭粍浠跺啓鍋?<${Foo}>
{a}
涔嬬被鐨勫瓧娈靛啓涓?${a}
鍏朵粬涓€鍒囦笌 JSX 鐩稿悓銆?/span>
濂芥枃鎺ㄨ崘锛?/strong>
鈥淯C鍥介檯鎶€鏈€濊嚧鍔涗簬涓庝綘鍏变韩楂樿川閲忕殑鎶€鏈枃绔?/span>
以上是关于鎯冲啓 JSX锛屽張涓嶆兂鐢ㄧ紪璇戝櫒锛烪TM 鍙互甯綘的主要内容,如果未能解决你的问题,请参考以下文章
200琛孞S浠g爜锛屽甫浣犲疄鐜板井鍨嬩唬鐮佺紪璇戝櫒锛堜汉浜洪兘鑳藉浼氾級
Spread props锛?/span><div ...${props}>
鑷叧闂爣绛撅細<div />
缁勪欢锛?<${Foo}>
锛堝叾涓?Foo
鏄粍浠跺紩鐢級
甯冨皵灞炴€э細<div draggable />
html 寮曞彿鍙€夛細<div class=foo>
缁勪欢缁撴潫鏍囪锛?<${Footer}>footer content<//>
閫氳繃 lit-html VSCode 鎻掍欢瀹炵幇璇硶楂樹寒鍜岃瑷€鏀寔
HTM 閫熷害鎻愬崌浜?20 鍊?/span> 馃殌
鈥︿綋绉缉灏忎簡 10锛?/span>
鈥﹂殢澶勮繍琛岋紙鍘熺敓 SSR锛侊級
璇硶鏃犻檺鎺ヨ繎 JSX
缂撳瓨閫熷害鎻愰珮20锛?/span>
鏇翠紭鐨勮緭鍑?/span>
杩樺甫鏉ヤ簡鏂拌娉曪紵
鏄殑锛屼絾鍒厡銆?鐜板湪鍐?HTM 鍩烘湰涓婂氨鏄湪鍐?JSX銆?/span>浣犲彧闇€瑕佽浣忎袱浠朵簨锛?/span>
<Foo>
涔嬬被鐨勭粍浠跺啓鍋?<${Foo}>
{a}
涔嬬被鐨勫瓧娈靛啓涓?${a}
鍏朵粬涓€鍒囦笌 JSX 鐩稿悓銆?/span>