简体   繁体   English

中的Javascript变量<script> tag

[英]Javascript variables in <script> tag

My knowledge of javascript is medium, sorry if this question seem too newbie 我对javascript的了解中等,如果这个问题看起来太新手了,抱歉

I call a (stripe) script to display the checkout, my 'desc' variable, which is properly in my page, is just not used in the tag. 我调用一个(stripe)脚本来显示结帐,我的'desc'变量恰好在我的页面中,只是未在标记中使用。 Instead I have 'desc'. 相反,我有“ desc”。

data-description='bonjour' works data-description ='bonjour' 作品

var desc = 'bonjour' data-description=desc does not work var desc ='bonjour'data-description = desc 不起作用

what am I missing here ? 我在这里想念什么?

<script
      src="https://checkout.stripe.com/checkout.js" class="stripe-button"
      data-key=""
      data-amount=amount
      data-name="<%= current_user.full_name %>"
      data-description=desc
      data-panel-label="Encaisser"
      data-label="Payer par carte"
      data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
      data-locale="fr"
      data-currency="eur">
    </script>

实际上,那里没有任何Javascript-您只有HTML标记,描述了script标签及其HTML属性 ,因此您不能使用var或Javascript的其他特定功能。

<script no javascript here because this is HTML, not JS>
  JS can only be used here, in the content of the script tag
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM