[英]Extends paper input in Polymer 3
我正在嘗試從Polymer 3擴展紙張輸入組件,如文檔所述,但我不能。 https://polymer-library.polymer-project.org/3.0/docs/devguide/dom-template#inherit
在下一個示例中,您可以嘗試使用代碼段。 問題是紙張輸入的導入沒有PaperInputElement導出,所以我無法導入。 您必須在這里查看: https : //unpkg.com/@polymer/polymer/polymer-element.js?module
你可以幫幫我嗎?
<script type='module'> import 'https://unpkg.com/@polymer/paper-input@3.0.1/paper-input.js?module'; import {PolymerElement, html} from 'https://unpkg.com/@polymer/polymer/polymer-element.js?module'; class DmInput extends PaperInputElement { static get template() { return html` <style> </style> <p>hi</p> <p>${super.template}</p> `; } } window.customElements.define('dm-input', DmInput); </script> <dm-input></dm-input>
我相信您嘗試在此處導入錯誤的文件,Paper-input只是使用PaperInputBehavior的ui組件。 在這種情況下,請嘗試用行為替換PaperInputElement,因為輸入元素使用的所有函數,屬性和事件都來自該行為。
class DmInput extends PaperInputBehavior { static get template() { return html` <style> </style> <p>hi</p> <p>${super.template}</p> `; } }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.