刚从材料组件开始。我正在尝试mdc-icon-toggle
,HTML 代码
<i class="mdc-icon-toggle material-icons" role="button" aria-pressed="false" aria-label="Add to favorites" tabindex="0"
data-toggle-on='{"label": "Remove from favorites", "content": "favorite"}'
data-toggle-off='{"label": "Add to favorites", "content": "favorite_border"}'
data-mdc-auto-init="MDCIconToggle">
favorite_border
</i>
JS代码
const iconEl = document.querySelector('.mdc-icon-toggle');
iconEl.addEventListener('MDCIconToggle:change', ({detail}) => {
alert(detail.isOn)
});
基本功能工作正常,我可以收听事件,但是当我单击图标时,涟漪效果无法正常工作,图标周围有阴影,从不。我是否也缺少单选按钮?