элемент
import { LitElement, html } from 'lit-element';
class Component extends LitElement {
render () {
return html`
<slot name="activator">
<button @click="${this.openDialog}">Default Button</button>
</slot>
<custom-dialog></custom-dialog>
`;
}
openDialog () {
// code to open dialog
}
}
customElements.define('custom-dialog', Component);
index.html
<head>
<script type="module" src="src/custom-dialog.js"></script>
</head>
<body>
<custom-dialog>
<button slot="activator">Outside Button</button>
</custom-dialog>
</body>
Учитывая указанный выше пользовательский компонент и мою реализацию на простой HTML-странице. Вы заметите, что я использую кнопку слота.
Как вызвать метод openDialog()
с помощью кнопки слота?
Я проверил документы о событиях, но не нашел ничего, имеющего отношение к этому.
Заранее спасибо.