amis
amis copied to clipboard
如何触发按钮隐藏/显示
如何通过按钮button1点击设置按钮button2 的隐藏/显示
需要改变一下作用域中的数据。方式有:
- 如果是 ajax 类型的按钮,可以接口返回个变量标识。
- 可以配置 reload: 'xxx?varName=true' ,通过配置 reload 给当前作用域设置个新值比如这里是 varName 值为字符串
true - 如果是表单内,建议直接用 checkbox 类型,这样勾选后能直接给表单项 name 设置的字段赋值为 true
然后另外一个按钮配置 visibleOn 就可以了如: !this.varName
{
"type": "button-group", // 按钮组
"buttons": [
{
"type": "button",
"label": "button1",
"actionType": "dialog",
"dialog": {
"title": "系统提示",
"body": "对你点击了"
}
},
{
"type": "button",
"label": "button2",
"actionType": "dialog",
"dialog": {
"title": "系统提示",
"body": "对你点击了"
},
"visibleOn": "!this.varName"
},
{
"type": "button",
"label": "button3",
"name": "btn",
"actionType": "dialog",
"dialog": {
"title": "系统提示",
"body": "对你点击了"
},
}
]
}
@2betop 刚接触amis,不是特别明白,代码如上,点击button1隐藏button2,应该怎么做
2. 可以配置 reload: 'xxx?varName=true' ,通过配置 reload 给当前作用域设置个新值比如这里是 varName 值为字符串
true
{
actionType:"reload",
reload: 'xxx?varName=true'
}
{
"type": "button-group", // 按钮组
"buttons": [
{
"type": "button",
"label": "button1",
"actionType": "reload",
"reload": 'xxx?varName=true'
},
{
"type": "button",
"label": "button2",
"actionType": "dialog",
"dialog": {
"title": "系统提示",
"body": "对你点击了"
},
"visibleOn": "!this.varName"
},
{
"type": "button",
"label": "button3",
"name": "btn",
"actionType": "dialog",
"dialog": {
"title": "系统提示",
"body": "对你点击了"
},
}
]
}
@2betop 我写成这样,但是还是不好使,点击button1没有任何反应