Appsmith - 官方文档

1,072 阅读1分钟
  1. api传递参数

    • 表达式:{{ Api1.run(()=>{}, ()=>{}, {k: v}) }}
    • API:https://xxx.com/?
  2. 上传文件:官方文档

  3. 获取异步函数的返回值:使用 asyncFunction.data 属性。

  4. localStorage本地存储

    • 存本地数据:{{storeValue('inputData', Input1.text)}}
    • 取本地数据:{{appsmith.store.inputData}}
  5. 表单提交数据:官方文档

  6. 单行表达式:

    {{updateData.run(() => {getData.run(), closeModal('ModalName')}, () => {})}}
    
  7. 多行表达式

    {{ 
      (function() {
          if (Dropdown.selectedOptionValue === "1") {
            return "Option 1";
          } else {
            return "Option 2";
          }
       })()
    }}
    
  8. JSObject不能跨page访问的限制:github地址

  9. 属性面板上的成功回调只能配置一次,但是可以切换到js编辑器写。

  10. 每一个QueryObject都有一个run()函数

  11. Promise.all() 一旦一个输入 promise 被拒绝就会拒绝,而 Promise.allSettled() 则会等待所有输入 promise 解决,而不管它们的结果如何。

  12. 表格分页:select * from users limit {{table1.pageSize}} offset {{(table1.pageNo - 1) * table1.pageSize}}

  13. 隐藏导航栏:app.appsmith.com/applications/xxx/pages/xxx?embed=true

  14. 解决图片下载跨域问题:{{download('cors.anywhere.herokuapp.com/真正的图片地址'}}

  15. 使用图片为背景:background属性值,url('图片地址')

  16. 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")