-
api传递参数
- 表达式:
{{ Api1.run(()=>{}, ()=>{}, {k: v}) }} - API:
https://xxx.com/?
- 表达式:
-
上传文件:官方文档
-
获取异步函数的返回值:使用
asyncFunction.data属性。 -
localStorage本地存储
- 存本地数据:
{{storeValue('inputData', Input1.text)}} - 取本地数据:
{{appsmith.store.inputData}}
- 存本地数据:
-
表单提交数据:官方文档
-
单行表达式:
{{updateData.run(() => {getData.run(), closeModal('ModalName')}, () => {})}} -
多行表达式
{{ (function() { if (Dropdown.selectedOptionValue === "1") { return "Option 1"; } else { return "Option 2"; } })() }} -
JSObject不能跨page访问的限制:github地址
-
属性面板上的成功回调只能配置一次,但是可以切换到js编辑器写。
-
每一个QueryObject都有一个
run()函数 -
Promise.all()一旦一个输入 promise 被拒绝就会拒绝,而Promise.allSettled()则会等待所有输入 promise 解决,而不管它们的结果如何。 -
表格分页:
select * from users limit {{table1.pageSize}} offset {{(table1.pageNo - 1) * table1.pageSize}} -
隐藏导航栏:app.appsmith.com/applications/xxx/pages/xxx?embed=true
-
解决图片下载跨域问题:{{download('cors.anywhere.herokuapp.com/真正的图片地址'}}
-
使用图片为背景:background属性值,
url('图片地址') -
appsmith嵌套网页,通信文档
- 网页端
// 注册:接受来自appsmith的消息 window.onmessage = (event) => { console.log('onmessage:', event.data) } // 发送消息给appsmith const iFrame = document.getElementById("appsmith-iframe"); const windowMessageButton = document.querySelector("#window-message"); windowMessageButton.addEventListener("click", () => { iFrame.contentWindow.postMessage("你好,我来自html", "https://localhost"); });- appsmith端
// 发送消息给网页 {{ postWindowMessage('发送数据', 'window', '*') }} // 注册:接受来自网页的消息 windowMessageListener("https://mywebsite.com", () => {}); // 注销 unlistenWindowMessage("https://mywebsite.com")