javascript - 扩展 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>
`;
}
}
推荐阅读
- r - 使用 Shiny App 中的按钮删除活动标签面板
- android - 样式在 Android 中无法按预期在 TextView 上工作
- python - Jupyter Notebook:在循环期间覆盖输出单元格而不是追加输出
- spring-boot - Spring REST端点返回StreamingResponseBody:30秒后的AsyncRequestTimeoutException
- c++ - C++ 中有没有办法保存一个对象,然后重新加载它,尽管它有一个指针作为属性?
- c++ - Doxygen 关于 C++ 代码中重载运算符&= 的警告
- scala - 如何在 GraphX 中使用 2 步连接计算入度
- r - 剂量反应曲线 - 错误的 x 线间距
- php - 从另一个 URL 返回后,选择选项不会保留
- google-apps-script - 在 Googles Sheet 宏语言中移动“活动”单元格