light-dark-switch是根据html标签类名驱动的Web Component,它可以在任何位置使用。
npm i light-dark-switch
in index.html
<script src='./node/moduels/light-dark-switch/light-dark-switch.js'></script>
in main.js
import 'light-dark-switch/light-dark-switch.js'
in main.ts
import 'light-dark-switch/light-dark-switch'
<light-dark-switch></light-dark-switch>
<light-dark-switch selected></light-dark-switch>
<light-dark-switch enable-sync></light-dark-switch>
<light-dark-switch disabled></light-dark-switch>
Property Name | Document |
---|---|
enable-sync | 使按钮在html的dark类名变更后同步 |
selected | 使按钮在首次渲染后的选择状态为已选择(selected),它会被html的实际类名影响 |
disabled | 使按钮不可用 |
Method | Returns |
---|---|
select() | void |
unSelect() | void |
enableSync() | void |
disableSync() | void |
isSelected() | boolean |
isDisabled() | boolean |
isSync() | boolean |