私は、SPAは、サーバー側のレンダリングではないことを、あなたが不足していると思います。少なくとも大半はしたがって、あなたがアクセスしたとき/何かあなたのウェブサーバーはそれをindex.htmlにリダイレクトしません。ただし、vuejsルーターのリンクをクリックすると、javascriptが動作しているにもかかわらずサーバー側では機能しないため、動作します。この問題を解決するには
、そう
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</ifModule>
それが誰かを役に立てば幸いようにindex.htmlをするために.htaccessを使用して、すべての要求をリダイレクトします!
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
....Your configuration
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
//handle client side routes
app.Run(async (context) =>
{
context.Response.ContentType = "text/html";
await context.Response.SendFileAsync(Path.Combine(env.WebRootPath, "index.html"));
});
}
}
の場合:
あなたは正しいです。私は自分のWebフレームワークまたはWebサーバーレベルで処理する必要があります。私はそれをチェックしようとします。ありがとう –