amp-bind-macro导致验证失败

时间:2018-01-11 16:44:40

标签: amp-html

我无法使用amp-bind-macro工作,甚至连https://www.ampproject.org/docs/reference/components/amp-bind#defining-macros-with-amp-bind-macro提供的示例都没有。

每当我添加一个amp-bind-macro标签时,我在验证过程中会收到以下错误:"标签& amp-bind-macro'是不被允许的。"

以下是我使用的来源:



<!doctype html>
<html ⚡>
<head>
  <meta charset="utf-8">
  <script async src="https://cdn.ampproject.org/v0.js"></script>
  <script async custom-element="amp-bind" src="https://cdn.ampproject.org/v0/amp-bind-0.1.js"></script>
  <link rel="canonical" href="https://ampbyexample.com/introduction/hello_world/">
  <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
  <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>
</head>
<body>
    <amp-state id="myCircle">
        <script type="application/json">
            {
                "radius": 0
            }
        </script>
    </amp-state>
    <amp-bind-macro name="circleArea" arguments="radius" expression="3.14 * radius * radius" />
    <div>
      The circle has an area of <span [text]="circleArea(myCircle.radius)">0</span>.
    </div>
    <button on="tap:AMP.setState({myCircle: {radius: 10}})">
        Set to 10
    </button>
    <button on="tap:AMP.setState({myCircle: {radius: 20}})">
        Set to 20
    </button>
</body>
</html>
&#13;
&#13;
&#13;

这是在开发模式下运行时的日志:

  

导航到http://localhost:8002/macro-test.html viewer-impl.js:707   由AMP提供支持? HTML - 版本1515614886756   http://localhost:8002/macro-test.html#development=1   content_script.js:24初始化内容脚本消息监听器   validator.js:426 AMP验证有错误:lx.error @   validator.js:426(匿名)@ validator.js:441 e.b @ validator.js:365   bu @ validator.js:368 Xt @ validator.js:368 Ot.j @ validator.js:368 Nt   @ validator.js:362 Promise已解决(异步)Kt @ validator.js:362 Jt @   validator.js:362 Zt @ validator.js:367 Pt @ validator.js:367   (匿名)@ validator.js:362 d.onreadystatechange @ validator.js:440   XMLHttpRequest.send(async)(匿名)@ validator.js:440 Ot @   validator.js:362 sx @ validator.js:440(匿名)@ validator.js:441   (匿名)@ viewer-impl.js:547 Promise已解决(异步)yl @   viewer-impl.js:547 h @ viewer-impl.js:702 @ @   url-replacements-impl.js:833 Kf.He @ url-replacements-impl.js:994   (匿名)@ url-replacements-impl.js:1007 Promise已解决(异步)   Qf @ url-replacements-impl.js:59 Kf.Na @ url-replacements-impl.js:1024   (匿名)@ url-replacements-impl.js:963 Promise已解决(异步)Mf   @ url-replacements-impl.js:960 Jf @ url-replacements-impl.js:827   (匿名)@ viewer-impl.js:674 Id @ bytes.js:84 initial @   viewer-impl.js:589 @ url-replacements-impl.js:833 Kf.He @   url-replacements-impl.js:994(匿名)@   url-replacements-impl.js:1007 Promise已解决(异步)Qf @   url-replacements-impl.js:59 Kf.Na @ url-replacements-impl.js:1024   (匿名)@ url-replacements-impl.js:963 Promise已解决(异步)Mf   @ url-replacements-impl.js:960 Jf @ url-replacements-impl.js:827   (匿名)@ viewer-impl.js:547(匿名)@ viewer-impl.js:743   validator.js:426 http://localhost:8002/macro-test.html:25:4标签   &#39;安培绑定宏&#39;是不被允许的。 lx.error @ validator.js:426   (匿名)@ validator.js:442 e.b @ validator.js:365 bu @   validator.js:368 Xt @ validator.js:368 Ot.j @ validator.js:368 Nt @   validator.js:362 Promise已解决(异步)Kt @ validator.js:362 Jt @   validator.js:362 Zt @ validator.js:367 Pt @ validator.js:367   (匿名)@ validator.js:362 d.onreadystatechange @ validator.js:440   XMLHttpRequest.send(async)(匿名)@ validator.js:440 Ot @   validator.js:362 sx @ validator.js:440(匿名)@ validator.js:441   (匿名)@ viewer-impl.js:547 Promise已解决(异步)yl @   viewer-impl.js:547 h @ viewer-impl.js:702 @ @   url-replacements-impl.js:833 Kf.He @ url-replacements-impl.js:994   (匿名)@ url-replacements-impl.js:1007 Promise已解决(异步)   Qf @ url-replacements-impl.js:59 Kf.Na @ url-replacements-impl.js:1024   (匿名)@ url-replacements-impl.js:963 Promise已解决(异步)Mf   @ url-replacements-impl.js:960 Jf @ url-replacements-impl.js:827   (匿名)@ viewer-impl.js:674 Id @ bytes.js:84 initial @   viewer-impl.js:589 @ url-replacements-impl.js:833 Kf.He @   url-replacements-impl.js:994(匿名)@   url-replacements-impl.js:1007 Promise已解决(异步)Qf @   url-replacements-impl.js:59 Kf.Na @ url-replacements-impl.js:1024   (匿名)@ url-replacements-impl.js:963 Promise已解决(异步)Mf   @ url-replacements-impl.js:960 Jf @ url-replacements-impl.js:827   (匿名)@ viewer-impl.js:547(匿名)@ viewer-impl.js:743   validator.js:443另见   https://validator.ampproject.org/#url=http%3A%2F%2Flocalhost%3A8002%2Fmacro-test.html   error.js:188 amp-bind:表达式评估错误   &#34; circleArea(myCircle.radius)&#34 ;. circleArea不受支持   功能。???

0 个答案:

没有答案