amis icon indicating copy to clipboard operation
amis copied to clipboard

service 下的 iframe 反复渲染

Open faceair opened this issue 6 years ago • 1 comments

实现场景:

我尝试使用 service 容器返回的数据构建 iframe 的 src 参数,渲染页面。

当前方案:

{
    type: 'service',
    api: '/api/amis/render?component=${selector.component}&search=${selector.search}&datasources=${alert.datasources}&from=${alert.from}&to=${alert.to}&query=${alert.query}',
    body: {
        type: 'iframe',
        name: 'alert-query-iframe',
        src: 'https://xxx.com/dashboard/script/halo.js?orgId=1&theme=light&target=${query}&datasource=${datasource}&from=${from}&to=${to}'
    }
}

存在的问题:

现在正常情况下会渲染两次 src,前一次 iframe 加载会在数据返回后 cancel,再渲染新的页面,能工作但不优雅。 image

有时候数据返回后不会触发重新渲染 src 或不触发 iframe 重新加载,加载的 iframe 页面就不对了。 image

我期望 iframe 能在 service 数据返回后再开始渲染,实现类似于 api 的 sendOn。

{
    type: 'service',
    api: '/api/amis/render?component=${selector.component}&search=${selector.search}&datasources=${alert.datasources}&from=${alert.from}&to=${alert.to}&query=${alert.query}',
    body: {
        type: 'iframe',
        name: 'alert-query-iframe',
        src: {
            url: 'https://xxx.com/dashboard/script/halo.js?orgId=1&theme=light&target=${query}&datasource=${datasource}&from=${from}&to=${to}',
            sendOn: 'query && query.length > 0'
        }
    }
}

faceair avatar Aug 26 '20 05:08 faceair

更新到最新版试下还有没有这个问题

RickCole21 avatar Nov 27 '20 09:11 RickCole21