脚本


setVariable功能
如果你想使用 Javascript 设置变量值,那么建议你去用“设置变量”组件。因为在大多数情况下“设置变量”组件更合适你的需求。
如果您执意想使用脚本组件设置变量,那么可以使用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变量名:

2、重新加载页面
window.location.reload()
3、页面提示
alert("这是脚本组件的提示")
4、如果变量具有特定值则重定向
if({{Category}} === 'qualified') {
window.location.href = 'https://codemossai.com/'
}
最后更新于
这有帮助吗?