ソリューション
找到src/router/index.js 文件添加代码
export default new Router({
mode: 'history', //修改部分
base: '/dist', //修改部分 如果你的次级文件夹名是dist 这里就配置dist
routes: [
{
path: '/',
name: 'HelloWorld',
component: HelloWorld
},
{
path: '/test.html',
name: 'Hello',
component: Hello
}
]
})
あなたはApacheサーバの場合は、httpd.confの設定ファイルのLoadModule rewrite_moduleモジュール/ mod_rewrite.soのコード行は、「#」記号を保存する削除は、Apacheを再起動して見つけます
その後、エラーをテストする方法の公式サイトに次のコードを追加し、新たな.htaccessファイルの下のフォルダDIST
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /dist/index.html [L] //注意这个
あなたは、ルートディレクトリサーバにある場合はnginxの
location / {
try_files $uri $uri/ /index.html;
}
ないルートディレクトリの下
location /your_router {
try_files $uri $uri/ /your_router/index.html;
}