国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

如何讓 FastAPI 為 Vue 3 執(zhí)行 SSR?
P粉004287665
P粉004287665 2023-08-26 21:31:32
0
1
969
<p>根據(jù) Vue 的 SSR 文檔,可以使用 node.js 渲染應(yīng)用程序并使用 Express 服務(wù)器返回它。 FastAPI 可以做同樣的事情嗎?</p> <p>或者使用 Jinja2 模板或 SPA 是唯一的解決方案嗎?</p> <h3>問題:</h3> <ul> <li>無 SPA:幫助進(jìn)行 SEO</li> <li>無 SSG:將生成太多頁面。有些需要?jiǎng)討B(tài)生成。</li> <li>沒有 Jinja2/Python 模板:不會(huì)構(gòu)建、捆綁和提供節(jié)點(diǎn)模塊。所有模塊都必須通過遠(yuǎn)程包 CDN 提供服務(wù)。</li> </ul> <p>我有一種感覺,也許更改 Vue 3 分隔符然后構(gòu)建項(xiàng)目并將文件作為 Jinja2 模板提供是解決方案,但我不確定它如何與 Vue 的路由器一起使用。我知道 <code>/dist</code> 文件夾可以在默認(rèn)路由上提供服務(wù),然后使用一個(gè)包羅萬象的可以用來顯示確實(shí)存在的文件。</p> <h3>可能的解決方案</h3> <pre class="brush:py;toolbar:false;">@app.get("/", response_class=FileResponse) def read_index(request: Request): index = f"{static_folder}/index.html" return FileResponse(index) @app.get("/{catchall:path}", response_class=FileResponse) def read_index(request: Request): path = request.path_params["catchall"] file = static_folder + path if os.path.exists(file): return FileResponse(file) index = f"{static_folder}/index.html" return FileResponse(index) </pre> <h3>問題</h3> <ul> <li>如果有一種方法可以使用 FastAPI 和 Vue 3 進(jìn)行 SSR,那是什么?</li> <li>如果沒有直接的方法,如何將 Vue 內(nèi)置的 <code>/dist</code> 與 Jinja2 模板結(jié)合起來提供動(dòng)態(tài)頁面?</li> </ul></p>
P粉004287665
P粉004287665

全部回復(fù)(1)
P粉282627613

有多種可用選項(xiàng),例如 Nuxt.js、Quasar 和 Gridsome,它們通過 FastAPI 和 Vue 3 提供對(duì) SSR 的支持。

最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板