我在js文件中的变量卡中有一段html代码,我发现正则表达式在卡变量error.All中不匹配,单引号和双引号matches.What中的正则表达式不匹配,我在html block.Is中做错了任何打字错误。
(function ($) {
Drupal.behaviors.one_time_popup = {
attach: function (context, settings) {
var celeType=Drupal.settings.one_time_popup.celeType;
card="<div class=\'cardTemplate-aniv\'>
<p class=\'bir-anniv-wishes\'>Happy Birthday and Successful Anniversary</p>
<p id=\'aspirian-name\'>"+userName+"</p>
<img src=\'"+Drupal.settings.publicpath+"/Birthday_Images/birthdayTemplate1.jpg\' style=\'width:250px;height:230px;\'>
<img src=\'"+Drupal.settings.publicpath+"/Anniversary_Images/"+anniversaryCount+"Anniversary.jpg\' style=\'width:250px;height:250px;\'>
</div>";
}
};
}(jQuery)); 我还有一个模板
cardTemplate1 = "<div class=\'cardTemplate\'><span class=\'birthdayImage\'></span><p class=\'wishes\'>Happy Birthday <span id=\'aspirian-name\'>"+userName+"</span> !</p><img src=\'"+Drupal.settings.publicpath+"/Birthday_Images/birthdayTemplate1.jpg\'></div>";它显示了不带转义单引号的正则表达式不匹配
发布于 2017-08-30 13:31:37
不能在双引号中包含多行字符串文字。如果您有ES6,则可以使用反引号来创建多行模板字符串。请参阅creating-multiline-strings-in-javascript
发布于 2017-08-30 13:29:34
您不需要转义单引号'。
https://stackoverflow.com/questions/45952533
复制相似问题