【问题标题】:Resolving undefined in email URL解决电子邮件 URL 中的未定义问题
【发布时间】:2017-07-26 20:39:19
【问题描述】:

我在 url url 中的变量 productsList 的链接上未定义任何想法可能是什么问题?

当我将鼠标悬停在链接上时,它会正确显示字符串,但当点击它时,它会变成未定义的

我的代码:

$(".emailCustomer").click(function(urlEmail){

      var invoiceNumber = $(this).closest("li").find(".invoiceNumber").text();
     // active subject invoice no.
      var emailAddress = $(this).data("email");
      var customerName = $(this).data("customer");
      var productsList = $(this).data("products");

      urlEmail = "https://mail.google.com/mail/?view=cm&fs=1&to="+emailAddress+"&su=+invoiceNumber+&body="+customerName+"%2C%0A%0A"+productsList+"%0A%0AEMAIL+SIGNATURE";
      $(this).attr("href" , urlEmail); 
      $(this).attr("target" , "_blank"); 
      return urlEmail;
     });


<a class="emailCustomer" href="https://mail.google.com/mail/?view=cm&fs=1&to="+emailAddress+"&su=+invoiceNumber+&body="+customerName+"%2C%0A%0A"+productsList+"%0A%0AEmail+Signature" data-email="{{i.email}}" data-customer="{{i.name}}" data-products="{{i.products}}" target="_blank">

【问题讨论】:

  • href和左引号之间应该有一个=。
  • 当你将鼠标悬停在它上面时,在什么情况下?变量从何而来?你能在这里添加更多细节吗?
  • 我的一般想法是在电子邮件正文中输入尽可能多的内容,变量 productsList 已经编码以替换 ()(^)_ 之类的字符编码

标签: javascript email gmail


【解决方案1】:

在您的 a 标签上,属性 data-products 未设置,因此在您的点击回调中 productsList 未定义。

【讨论】:

  • 抱歉忘了把数据产品放在这个问题上,但它在我的开发中,我会更新它
猜你喜欢
  • 1970-01-01
  • 2019-10-29
  • 1970-01-01
  • 2020-01-27
  • 2020-04-24
  • 2022-07-20
  • 2012-11-26
  • 1970-01-01
  • 2020-11-18
相关资源
最近更新 更多