如何刪除此錯誤"響應必須在"處包含數組。創建下拉菜單時(&Q;) [英] how to remove this error "Response must contain an array at " . "." while making dropdown

查看:0
本文介紹了如何刪除此錯誤"響應必須在"處包含數組。創建下拉菜單時(&Q;)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我在創建下拉菜單時遇到此錯誤。我從以下位置閱讀文檔 這里 https://ampbyexample.com/advanced/linked_dropdowns/

響應必須在"."處包含數組。

我發現很少有鏈接提供了一些解決方案,但沒有人對我起作用 https://github.com/ampproject/amphtml/issues/10613

https://github.com/ampproject/amphtml/issues/9687

以下是我的代碼 https://jsbin.com/paviyezihu/edit?html,js,output

HTML

    <!doctype html>
    <html ?>
    <head>
      <title>Linked Dropdowns</title>
      <link rel="canonical" >

      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
      <script async src="https://cdn.ampproject.org/v0.js"></script>
      <!-- #### Setup -->
      <!-- First we include `amp-bind` to track the page state and update the ``<amp-list>` data source. -->
      <script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
      <!-- Next we include `amp-list` to request and display the dropdowns and their options. -->
      <script async custom-element="amp-list" src="https://cdn.ampproject.org/v0/amp-list-0.1.js"></script>
      <!-- Finally, we include `amp-mustache` to render the mustache templates inside the `<amp-list>`s. -->
      <script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.1.js"></script>

      <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>

      <style amp-custom>
        label {
          font-weight: bold;
        }

        [role="listitem"] {
          display: flex;
        }

        [role="listitem"] > * {
          flex: 1 0 0;
        }

        amp-list {
          margin: 10px 20px;
          min-width: 240px;
        }

      </style>
    </head>
    <body>

    <div>
    <amp-list width="auto" items="." height="25" layout="fixed-height" src="https://biz.timesofindia.indiatimes.com/bankifsc/getlist">
        <template type="amp-mustache">
          <label for="country">Country:</label>
          <select id="country" 
          >
            <option value="">Choose a country</option>
            {{#data}}
              <option value="{{text_val}}">{{text_val}}</option>
            {{/data}}
          </select>
        </template>
    </amp-list>

    <!-- <amp-state id="dropdown" src="https://ampbyexample.com/json/linked_dropdowns.json"></amp-state>
     --></div>

    </body>

</html>

推薦答案

single-item屬性添加到amp-list

<amp-list width="auto" single-item items="." height="25" layout="fixed-height" src="https://biz.timesofindia.indiatimes.com/bankifsc/getlist">
    <template type="amp-mustache">
      <label for="country">Country:</label>
      <select id="country">
        {{#data}}
          <option value="{{text_val}}">{{text_val}}</option>
        {{/data}}
      </select>
    </template>
</amp-list>

選中jsbin

這篇關于如何刪除此錯誤&quot;響應必須在&quot;處包含數組。創建下拉菜單時(&Q;)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持IT屋!

查看全文
登錄 關閉
掃碼關注1秒登錄
發送“驗證碼”獲取 | 15天全站免登陸
全免费A级毛片免费看无码播放