首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >framework7虚拟列表无条目

framework7虚拟列表无条目
EN

Stack Overflow用户
提问于 2017-01-10 21:11:31
回答 0查看 633关注 0票数 0

我尝试用json在framework7中创建一个虚拟列表。在Chrome中没有错误。当我将json写到控制台时,我看到了它。我不知道哪里出了问题。

也许你能帮我。

代码语言:javascript
复制
var template = $$('#customer-template').html();

// Compile and render
var compiledTemplate = Template7.compile(template);

// Defined as function "getrandom"
function getrandom() {
  // Get JSON Data from UrbanDictionary API
  $$.getJSON('../api.php?getCustomer', function (json) {
    console.log(json);
      $$('#content-wrap').html(compiledTemplate(json))
  });
};

// Execute to list UrbanDictionary Definitions
getrandom();

这是我的html部分。

代码语言:javascript
复制
 <div id="view-2" class="view tab">
        <div class="pages">
          <div data-page="index-2" class="page">
            <div class="page-content">
              <div class="content-block">
                <div id="content-wrap"></div>
                <script id="customer-template" type="text/template7">
                   <div class="list-block media-list">
                     <ul>
                       {{#each list}}
                       <li><a href="details.html" class="item-link">
                           <div class="item-content">
                             <div class="item-inner">
                               <div class="item-title">{{surname}}, {{forename}}</div>
                             </div>
                           </div></a></li>{{/each}}
                     </ul>
                   </div>
                 </script>
              </div>
            </div>
          </div>
        </div>
      </div>

我的json看起来像这样

代码语言:javascript
复制
   [
  {
    "cid": "266",
    "title": "",
    "surname": "Kiefer",
    "forename": "Peter",
    "company": "sdfg",
    "role": "CEO",
    "position": "",
    "tel_work": "0123456789",
    "tel_mobile": "0123456789t",
    "fax_work": "0123456789",
    "adr_work_street": "sdfg",
    "adr_work_zip": "sdfg",
    "adr_work_place": "sdfg",
    "adr_work_country": "sdfg",
    "email_work": "sdfg",
    "website": "sdfg"
  }
]
EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41569675

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档