cwco
Release 1.7.8
創建的Contextfull Web組件庫旨在改善本地Web組件API用戶體驗:
該模塊也可以在節點環境中直接在瀏覽器中使用。您甚至可以將其與其他Web庫和框架一起使用,例如React和Angular 。
<!-- use the latest version -->
< script src =" https://unpkg.com/cwco/dist/cwco.min.js " > </ script >
<!-- use a specific version -->
< script src =" https://unpkg.com/[email protected]/dist/cwco.min.js " > </ script >
<!-- link your app script after -->
< script src =" app.js " > </ script > npm install cwco
然後,您可以根據所構建的內容導入構造函數類。
const { WebComponent , ContextProviderComponent , Directive } = require ( 'cwco' ) ;CWCO只是HTML,如果您想為VSCODE進行語法突出顯示,則可以使用Inline-HTML
為了在JavaScript中突出顯示HTML和CSS的語法,請使用內聯HTML或LIT-HTML插件。
您可以從cwco導入html ,這只是對VSCODE的幫助,這對您使用的HTML字符串沒有什麼特別的作用。
import { html , css , WebComponent } from "./cwco" ;
class MyButton extends WebComponent {
get template ( ) {
return html `<button><slot></slot></button>`
}
get stylesheet ( ) {
return css `<style>button {color: #222}</style>`
// or
// return css`button {color: #222}`
}
} 這些IDE具有內置的HTML In-JavaScript語法突出顯示,在開發CWCO Web組件時可能很有用。
了解如何