2015-01-01 29 views
1
<html> 
<head> 
    <title>core-icon-button</title> 

    <script src="../webcomponentsjs/webcomponents.js"></script> 

    <link rel="import" href="core-icon-button.html"> 
    <style> 
    </style> 

</head> 

<body unresolved> 


<template is="auto-binding"> 
    <template repeat="{{icon in $.meta.metaData.icons.iconNames}}"> 
     <core-icon-button icon="{{icon}}" title="{{icon}}"></core-icon-button> 
    </template> 
    <core-icon-button icon="menu"><span>label</span></core-icon-button> 
    </div> 
    <core-iconset id="meta"></core-iconset> 
</template> 

</body> 
</html> 

請能有人向我解釋,爲什麼沒有「進口」所使用的核心圖標集元素被使用? 對不起我的英文不好。 非常感謝。爲什麼<核心圖標集>可以沒有「進口」聚合物

回答

1

如果我們看一看在core-icon-button.html文件,在頂部我們發現以下兩行:

<link rel="import" href="../core-icon/core-icon.html"> 
<link rel="import" href="../core-icons/core-icons.html"> 

core-icon反過來進口core-iconset

<link rel="import" href="../core-iconset/core-iconset.html"> 

所以核心圖標集。 html通過這個導入鏈被導入。

每個元素都會導入其所需的所有其他元素,以便元素的客戶端不負責導入依賴項。而且,由於這些導入(更確切地說是元素註冊)是全局的(並且不是導入元素的範圍),因此可以在導入後的任何位置使用這些元素。