如何显示聚合物对话框



我正试图通过显示一个简单的消息对话框来开始使用谷歌的聚合物纸元素1.0:

<html>
<head>
   <script src="scripts/polymer/webcomponentsjs/webcomponents.min.js"></script>
</head>
<body>
<paper-dialog opened="true">Dialog test</paper-dialog>
</body>
</html>

页面上出现了"对话测试"字样,但是没有对话。有人知道我错过了什么吗?

您缺少对paper-dialog元素定义的引用。

<html>
    <head>
        <title>Example</title>
        <script src="path/to/webcomponentsjs/webcomponents-lite.js"></script>
        <link rel="import" href="path/to/paper-dialog/paper-dialog.html" />
    </head>
    <body>
        <paper-dialog opened="true">Dialog test</paper-dialog>
    </body>
</html>

包含适当的导入(<link rel="import" href="path/to/paper-dialog/paper-dialog.html" />)将允许元素被浏览器识别,并提供您期望的功能,包括行为和样式。

有关使用web组件的交互式教程,您可以查看component.kitchen.

最新更新