элемент
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()
с помощью кнопки слота?
Я проверил документы на события , но не нашел ничего подходящего для этого.
Заранее спасибо.