如何删除此错误"响应必须在"处

how to remove this error quot;Response must contain an array at quot; . quot;.quot; while making dropdown(如何删除此错误quot;响应必须在quot;处包含数组。创建下拉菜单时(Q;))

本文介绍了如何删除此错误"响应必须在"处包含数组。创建下拉菜单时(&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" href="https://ampbyexample.com/advanced/linked_dropdowns/">

      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
      <script async src="aHR0cHM6Ly9jZG4uYW1wcHJvamVjdC5vcmcvdjAuanM="></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="aHR0cHM6Ly9jZG4uYW1wcHJvamVjdC5vcmcvdjAvYW1wLWJpbmQtMC4xLmpz"></script>
      <!-- Next we include `amp-list` to request and display the dropdowns and their options. -->
      <script async custom-element="amp-list" src="aHR0cHM6Ly9jZG4uYW1wcHJvamVjdC5vcmcvdjAvYW1wLWxpc3QtMC4xLmpz"></script>
      <!-- Finally, we include `amp-mustache` to render the mustache templates inside the `<amp-list>`s. -->
      <script async custom-template="amp-mustache" src="aHR0cHM6Ly9jZG4uYW1wcHJvamVjdC5vcmcvdjAvYW1wLW11c3RhY2hlLTAuMS5qcw=="></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="aHR0cHM6Ly9iaXoudGltZXNvZmluZGlhLmluZGlhdGltZXMuY29tL2JhbmtpZnNjL2dldGxpc3Q=">
        <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="aHR0cHM6Ly9hbXBieWV4YW1wbGUuY29tL2pzb24vbGlua2VkX2Ryb3Bkb3ducy5qc29u"></amp-state>
     --></div>

    </body>

</html>

推荐答案

single-item属性添加到amp-list

<amp-list width="auto" single-item items="." height="25" layout="fixed-height" src="aHR0cHM6Ly9iaXoudGltZXNvZmluZGlhLmluZGlhdGltZXMuY29tL2JhbmtpZnNjL2dldGxpc3Q=">
    <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;)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何删除此错误&quot;响应必须在&quot;处