flutter build web 在构建文件上没有显示任何内容后不起作用显示空白

时间:2021-06-30 15:11:51

标签: flutter build flutter-web

在 flutter run -d chrome 上运行罚款,但在构建后的 flutter build web 上我从 build/web/index.html 运行 build index.html 只显示空白屏幕并在控制台中显示一些错误,请注意这是 flutter counter 应用程序.

Consoles errors screenshot

1 个答案:

答案 0 :(得分:1)

您需要通过某个应用程序服务器运行它,请参阅下面的示例以使用 ExpressJs 在节点服务器上运行它。

const express = require('express')
const app = express()
const port = 3000

// add web folder path created after flutter build
app.use(express.static('your_web_folder_path'))

app.listen(port, () => {
  console.log(`Example app listening at http://localhost:${port}`)
})