gpt4 book ai didi

flutter - 如何在 Heroku 上部署 Flutter Web

转载 作者:行者123 更新时间:2023-12-04 13:55:57 44 4
gpt4 key购买 nike

我在 flutter 中构建了一个 web 应用程序并成功运行命令 flutter build web。我试图找到一种方法将它部署在 Heroku 上,就像我的 React 应用程序一样,但在 heroku 文档中什么也没找到。

最佳答案

我们在 php 的帮助下运行 flutter web 或静态页面运行。我们可以使用许多其他语言。我们可以简单地使用 php 而无需更多工作。

第一的
之后会显示在heroku中创建应用程序。 enter image description here
运行后 flutter build web在项目文件夹的根目录中,它将在 build/web 中生成静态内容。将文件复制到任何其他目录并像这样打开 cmd
enter image description here
创建两个文件 index.php 和 composer.json
在 index.php 中
添加这个

echo '<?php include_once("index.html"); ?>'

在 composer.json 中
添加这个(大括号)
{} 
enter image description here
运行命令后
`heroku login`
heroku git:clone -a appname
git add .
git commit -am "make it better
git push heroku master
运行后它可能会显示任何错误。如果不显示任何错误
运行此 https://appname.herokuapp.com/#/ .您的网站将上线。

关于flutter - 如何在 Heroku 上部署 Flutter Web,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62397807/

44 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com