如何使用双引号在伪造查看器模型中有效搜索?

问题描述

Decorator Pattern 博文中,Augusto 表明,如果我使用如下双引号

viewer.search('"GRIdpl 2 of GRIDFACES 1 of REFGrd /144CAGRIDS_E3D/WET-END"',(ids)=>{console.log(ids)},['Name']);

搜索速度非常快。是的,这是真的。但是当属性名称存储在变量中时,如何使用双引号? 我尝试了几种方法但没有运气 -

let s = "GRIdpl 2 of GRIDFACES 1 of REFGrd /144CAGRIDS_E3D/WET-END";
viewer.search('\'' + s + '\'',['Name']) //[]
viewer.search('\'"' + s + '"\'',['Name']) //[]
viewer.search(`'"${s}"'`,['Name']) //[]

以上所有都给出了空数组,如下图- this

你能帮忙吗?

TIA

解决方法

您错过了最后一个变体,而这正是您所需要的:

<div class='foo'>
  <img src="https://source.unsplash.com/random/200x200" />
  <div class="foocontent">
    Here's some text and even some more text to demonstrate how text content could be placed above the image that serves as a background here.
  </div>
</div>