елемент
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()
с помощта на бутона на слота?
Проверих документи за събития, но не намерих нищо свързано с това.
Благодаря предварително.