1

是否可以在中制作子 Web 组件Dart

比如说,我有一个x-chatwindow自定义元素,我希望它有一个x-textareax-textinput子组件。

一个虚构的实现是:

<x-chatwindow>
    <x-textarea/>
    <x-textinput/>
</x-chatwindow>
4

2 回答 2

2

Is there a specific problem you are facing?

You can use the <content></content> inside your ChatWindowComponent template:

<element name="x-chat-window" constructor="ChatWindowComponent" extends="div">
  <template>
    <content></content>
  </template>
</element>

Then the page where you use them:

<!DOCTYPE html>
<html>
  <head>
    <link rel="components" href="components/chat_window.html" />
    <link rel="components" href="components/text_area.html" />
    <link rel="components" href="components/text_input.html" />
  </head>
  <body>
    <x-chat-window>
      <x-text-area></x-text-area>
      <x-text-input></x-text-input>
    </x-chat-window>
  </body>
</html>
于 2013-01-26T16:27:50.097 回答
1

在“Dart M3”、“Dart Editor build 20259”和“web_ui 0.4.2 + 5”上测试的答案

除了 Kai Sellgren 的回答,WebComponents 可以隐藏在其他 WebComponents 中。在“xchatwindow.html”内的情况下,文本区域和文本输入可以链接为;

<!DOCTYPE html>

<head>
  <link rel="components" href="components/xtextarea.html">
  <link rel="components" href="components/xtextinput.html">
</head>
<body>
  <element name="x-chat-window" constructor="FormComponent" extends="div">

...
于 2013-03-26T17:19:32.313 回答