如何加载外部html文件? [英] How to load a external html file?

查看:60
本文介绍了如何加载外部html文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想将 .html 文件加载到我的 UI5 应用程序中的 JS 视图中.此文件是包含一些图表的外部页面..

I just want to load a .html file into a JS view in my UI5 Application. This file is an external page that contains some charts..

我尝试了很多东西,但都没有成功..

I'm trying many things, but no success..

如果有人可以帮助我,非常感谢.

Thank you very much if anyone could help me on that.

推荐答案

你尝试过哪些很多事情"?

What were those "many things" you tried?

一般的做法是使用sap.ui.core.HTML控件将其他HTML页面嵌入为iframe,看这个例子:http://jsbin.com/dutuparedeyu/1/edit?html,output

The general approach is to embed the other HTML page as an iframe, using the sap.ui.core.HTML control, see this example: http://jsbin.com/dutuparedeyu/1/edit?html,output

new sap.ui.core.HTML({
  preferDOM: true,
  content: "<iframe src='http://www.sap.com'></iframe>"
});

根据 HTML 页面,您也可以使用 Ajax 调用加载它,提取要显示的 HTML 并使用 sap.ui.core.HTML 控件显示它.但是,当另一个页面的头部加载了脚本和 CSS 并且您也必须加载到您的应用程序页面时,这种方法就变得困难了.

Depending on the HTML page you could alternatively load it with an Ajax call, extract the HTML you want to display and also display it with the sap.ui.core.HTML control. But this approach gets difficult when the other page has scripts and CSS loaded in the head that you would also have to load into your application page.

这篇关于如何加载外部html文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆