我使用 Iframe 在我的网站中嵌入了 flutter web 应用程序。在网站上,我有一个简单的文本区域,在 flutter web 应用程序中,我还有一个文本小部件。我想要的功能是,当我在此文本区域中写入内容时,它也应该立即显示在我的 flutter web 应用程序中。目前我正在通过将 url 参数传递给 iframe 的 src 属性来完成此操作。但它重新启动我的 flutter web 应用程序时速度非常慢。
问题不在于将 flutter web 应用程序嵌入到网站中。我的问题是我们如何通过浏览器更改flutter web应用程序的数据.我想要快速实现的功能 https://drive.google.com/file/d/1iUyH9NnAOalPzU3ut7MtJVa5O7lWSeji/view?usp=sharing
我不想像下面的代码那样通过传递 url 参数来做到这一点,因为它非常慢。
<!DOCTYPE html>
<html>
<body>
<input id='input' type="text">
<input type="button" onclick="changeText()" value="Change" />
<h1>The web application that is embeding flutter app</h1>
<div id = 'main'>
<div>
<iframe src="http://localhost:54827/#/" width="800px" height="600px"
style="overflow:auto;border:5px ridge blue"> </iframe>
</div>
</div>
</body>
<script>
var changeText = ()=>{
var textToDisplay = document.getElementById("input").value;
var frame = document.createElement('iframe');
frame.setAttribute('src', `http://localhost:55035/#/?answer=${textToDisplay}`);
frame.setAttribute('height', '600')
var main = document.getElementById("main");
main.innerHTML ='';
document.getElementById("main").appendChild(frame);
}
</script>
</html>
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)