首页 > 解决方案 > 如何在 EXTJS 中自动重新加载框架?

问题描述

iframe我在 EXTJS 中有一个组件,我在其中加载外部 html 文件:

        {
                xtype: "component",
                border: false,
                layout: 'fit',
                flex: 1,
                autoEl: {
                    width: '100%',
                    height: '100%',
                    tag: "iframe",
                    src: 'resources/startpage/index.html'
                }
        }    

我希望 iframe 在我更改外部 html 文件时自动加载新内容,但它会加载缓存中的先前文件。有没有办法做到这一点?

通过类比图像文件,我试图把

src: 'resources/startpage/index.html' + '?_dc=' + (new Date())*1

但这不起作用,

标签: javascripthtmlcachingiframeextjs

解决方案


您是否尝试将其绑定到视图模型

视图.js

{
  xtype: 'container',
  bind: {
    html: '<iframe src="resources/startpage/index.html?_dc={myDc}" style="width: 100%; height: 100%; border: none;"/>'
  }
}

视图模型.js

 formulas: {
  myDc: {
    get(){
      return (new Date())*1;
    }
  }
}

推荐阅读