Amp html AMP电子邮件附加动态参数

Amp html AMP电子邮件附加动态参数,amp-html,amp-email,Amp Html,Amp Email,在AMP中,我希望根据用户选择动态更改链接参数。例如,如果用户选择选项1,我需要附加一个option=1的参数。这种实现是可能的还是有其他方法可以实现。我需要追加的原因是我想用这个参数加载url。使用param提交的表单不适用于此实现 <amp-selector layout="container" on="select: AMP.setState({ currentSelection: event.targetOption, })" class="sample-selec

在AMP中,我希望根据用户选择动态更改链接参数。例如,如果用户选择选项1,我需要附加一个option=1的参数。这种实现是可能的还是有其他方法可以实现。我需要追加的原因是我想用这个参数加载url。使用param提交的表单不适用于此实现

<amp-selector layout="container"  on="select: AMP.setState({
    currentSelection: event.targetOption,

  })" class="sample-selector" >
    <amp-img 
    src="https://amp.dev/static/img/docs/tutorials/firstemail/photo_by_caleb_woods.jpg" 
    width="50" height="50" 
    option="neutral" 
    ></amp-img>
    <amp-img 
      src="https://amp.dev/static/img/docs/tutorials/firstemail/photo_by_craig_mclaclan.jpg" 
      option="good" 
      width="50" height="50" option="good"></amp-img>
  </amp-selector>


  <button>
    <a href="https://mysite/page.jsp?param=234" 
      data-amp-addparams="response=currentSelection"
      >Click Button</a></button>


我想在currentSelection中附加值作为参数。

变量替换可能满足您的需要。在AMP,Links()中,允许在字符串内部使用变量并用相应的实际值替换

支持的变量:

<a
  href="https://example.com?abc=QUERY_PARAM(abc)"
  data-amp-replace="CLIENT_ID QUERY_PARAM"
  data-amp-addparams="client_id=CLIENT_ID(bar)&linkid=l123"
  >Go to my site</a
>
  • 客户识别码
  • 查询参数(参数)
  • 链接替换需要每次使用选择加入作为附加的安全措施 并确认使用变量替换的意图。这是 通过指定名为data amp replace的附加属性来完成 使用字符串值,该字符串值包含以空格分隔的 需要替换的变量

    示例:

    <a
      href="https://example.com?abc=QUERY_PARAM(abc)"
      data-amp-replace="CLIENT_ID QUERY_PARAM"
      data-amp-addparams="client_id=CLIENT_ID(bar)&linkid=l123"
      >Go to my site</a
    >
    
    。这里有一个参数提交的示例。表单上也允许使用变量替换。也来看看吧


    中也有一个讨论,看起来与您试图实现的目标类似。

    由于无法在AMP中绑定到
    [href]
    ,因此也不支持URL替换,实现这一点的一种方法是在标记中有多个链接,并通过绑定到
    [hidden]来显示/隐藏它们
    根据您的选择:

    <amp-selector layout="container"  on="select: AMP.setState({
        currentSelection: event.targetOption,
    
      })" class="sample-selector" >
        <amp-img 
        src="https://amp.dev/static/img/docs/tutorials/firstemail/photo_by_caleb_woods.jpg" 
        width="50" height="50" 
        option="neutral" 
        ></amp-img>
        <amp-img 
          src="https://amp.dev/static/img/docs/tutorials/firstemail/photo_by_craig_mclaclan.jpg" 
          option="good" 
          width="50" height="50" option="good"></amp-img>
      </amp-selector>
    
    
        <a href="https://mysite/page.jsp?param=neutral" 
          [hidden]="currentSelection != 'neutral'"
          >Click Button</a>
    
        <a href="https://mysite/page.jsp?param=good" 
          [hidden]="currentSelection != 'good'"
          >Click Button</a>
    

    如果我理解正确,问题是关于电子邮件,它不允许变量替换,也不允许绑定到
    [href]