最后更新于9个月前
这有帮助吗?
“脚本”组件只能执行 Javascript 代码。
注意:
如果你在“脚本”组件中加了双引号,那么脚本中的变量不会被解析。
所以你需要写console.log({{My variable}})
console.log({{My variable}})
而不是写console.log("{{My variable}}")
console.log("{{My variable}}")
如果您执意想使用脚本组件设置变量,那么可以使用setVariable在脚本中定义变量函数。例如:
setVariable
if({{My variable}} === 'foo') { setVariable('My variable', 'bar') } else { setVariable('My variable', 'other') }
注意:setVariable功能,只能在服务器上执行的脚本中使用,如果你开启了“在客户端执行”,那么setVariable将不会起到任何作用。
1、通过变量传递参数
1、在输入本文组件,定义一个变量名:My variable
2、在脚本组件设置变量名为:My variable
3、在气泡组件内输出My variable变量名:
window.location.reload()
alert("这是脚本组件的提示")
if({{Category}} === 'qualified') { window.location.href = 'https://codemossai.com/' }
还有很多 Javascript 代码可以执行,这将需要您自行挖掘
如果你想使用 Javascript 设置变量值,那么建议你去用“”组件。因为在大多数情况下“”组件更合适你的需求。