【问题标题】:how to get url parameter in AMP pages如何在 AMP 页面中获取 url 参数
【发布时间】:2017-01-04 23:18:49
【问题描述】:

是否可以获取 url 参数以在 amp 页面中使用?

假设我的页面是 www.mydomain.com/index.amp.html

我想像这样向那个页面传递一个参数 www.mydomain.com/index.amp.html?someparameter=myvalue

我想像这样 {{ someparameter }} 使用它来显示/获取值 "myvalue"

谢谢 J

【问题讨论】:

    标签: amp-html


    【解决方案1】:

    基于此thread,此功能将在非查看器场景中起作用,但在查看器内部不起作用。这是来自 link 的代码 sn-p:

    this.set_('QUERY_STRING', (param, defaultValue = "") => {
          assert(param, 'The first argument to QUERY_STRING, the query string ' +  /*OK*/'param is required');
          const url = parseUrl(this.win_.location.href);
          const params = parseQueryString(url.search);
    
          return (typeof params[param] !== "undefined") ?
    

    【讨论】:

      猜你喜欢
      • 2018-06-12
      • 2012-06-23
      • 1970-01-01
      • 2014-12-13
      • 2018-03-29
      • 1970-01-01
      • 2014-12-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多