npm install @polymer/iron-icons html <link rel="import" href="../iron-icons/iron-icons.html"> html <iron-icon icon="add"></iron-icon> html <iron-icon icon="add" style="color: red;"></iron-icon> html <button> <iron-icon icon="save"></iron-icon> </button> html <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>Iron Icon Button</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2.7.0/bundles/"> <script type="module"> import {html, PolymerElement} from 'https://unpkg.com/@polymer/polymer@3.2.0/lib/legacy/polymer-fn.js'; import '@polymer/iron-icons/iron-icons.js'; import '@polymer/iron-icon/iron-icon.js'; class IronIconButton extends PolymerElement { static get template() { return html` <style> :host { display: inline-block; } button { background-color: #007bff; color: white; border: none; border-radius: 4px; padding: 8px 16px; } </style> <button> <iron-icon icon="[[icon]]"></iron-icon> <slot></slot> </button> `; } static get properties() { return { icon: { type: String, value: 'add' } }; } } customElements.define('iron-icon-button', IronIconButton); </script> </head> <body> <h1>Iron Icon Button</h1> <script src="https://cdn.jsdelivr.net/npm/@webcomponents/webcomponentsjs@2.7.0"></script> </body> </html>


上一篇:
下一篇:
切换中文