Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
html模板文字-基于内部div迭代器属性隐藏外部div(lit html)_Html_Angular2 Template_Lit Element_Lit Html - Fatal编程技术网

html模板文字-基于内部div迭代器属性隐藏外部div(lit html)

html模板文字-基于内部div迭代器属性隐藏外部div(lit html),html,angular2-template,lit-element,lit-html,Html,Angular2 Template,Lit Element,Lit Html,我有这样的收藏 const CollectionItems = { [ "samsung":{ "battery":"2200mAh", "series":"S", "region":"inside", "instock"

我有这样的收藏

const CollectionItems = {
 [
   "samsung":{
              "battery":"2200mAh",
              "series":"S",
              "region":"inside",
              "instock":"Y",
              "open-issues":4,
              "shipment-progress":"ontrack"
            }
],
[
   "apple":{
              "battery":"2800mAh",
              "series":"11",
              "region":"outside",
              "instock":"Y",
              "open-issues":2,
              "shipment-progress":"ontrack"
            }
],
[
   "Oppo":{
              "battery":"3300mAh",
              "series":"E",
              "region":"inside",
              "instock":"Y",
              "open-issues":7,
              "shipment-progress":"delayed"
            }
],
[
   "Nokia":{
              "battery":"2300mAh",
              "series":"N",
              "region":"inside",
              "instock":"N",
              "open-issues":5,
              "shipment-progress":"delayed"            
            }
],
[
   "OnePlus":{
              "battery":"3800mAh",
              "series":"6",
              "region":"outside",
              "instock":"Y",
              "open-issues":3,
              "shipment-progress":"ontrack"
            }
]
}
现在,我尝试使用lit html的repeat指令(相当于ngFor)遍历这个集合,我想隐藏所有属于“内部”区域的项。我有一个类级变量“this.isInSideRegion”,其默认值为false,如果在集合中遇到内部区域项,我会将其设置为true

return repeat(Object.entries(CollectionItems), (p) => p[0], (p) => {
      return html`
        <div class ='card' ?hidden = ${this.isInSideRegion === true }> <!-- hide this whole div if 'region' is inside -->
          <label>p[0]</label>
          <div class="container">
          ${p[1].map((l)=> html`
          ${l.region !== 'inside' ? html`
          <span>${l.openIssues}</span>
          <span>${l.instock}</span>
          `: this.isInSideRegion = true }
          `)}
          </div>
        </div>
        `;
    });

如我所料,其中是一个空模板

“hidden”属性在lit html中没有任何意义。“隐藏”指令是特定于角度的。您应该使用lithtml的“styleMap”或“classMap”指令来添加条件样式。请参考他们的样式以了解更多详细信息。

在html中,“隐藏”属性并不表示任何内容。“隐藏”指令是特定于角度的。您应该使用lithtml的“styleMap”或“classMap”指令来添加条件样式。请参考他们的样式以了解更多详细信息。

为什么不使用
?hidden=p.region==='inside'
为什么不使用
?hidden=p.region=='inside'
samsung
false