作者:昕谊凡 | 来源:互联网 | 2023-08-19 17:01
router/index.js
1 2 3 4 5 6
| export default new Router({
mode:'history',
scrollBehavior: () => ({ y: 0 }),
base:'/app/',
routes
}) |
router/routers.js
已去掉默认的/根路径
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| export default [
{
path: '/list',
name: 'list',
component: list
},
{
path: '/add',
name: 'add',
component: add
},
{
path: '*',
name: "notfound",
component: notfound
}
] |
components/top.vue
www/app/.htaccess
1 2 3 4 5 6 7
| Options +FollowSymLinks
RewriteEngine On
RewriteBase /app
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /app/index.html [L] |
www目录文件结构
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| │ index.html
│
└─app
│ .htaccess
│ index.html
│
└─static
├─css
│ app.7233ee7e6d1b85caf3dfeb523a903d26.css
│ app.7233ee7e6d1b85caf3dfeb523a903d26.css.map
│
├─fonts
│ element-icons.6f0a763.ttf
│
└─js
app.9a37ce9f652cfbd33f67.js
manifest.baa9bea5c1ebe2b4f949.js
vendor.d6c5e8fb459ec2cc8669.js |
编译好的项目已经在/app下能够正常运行访问了
既然设置了base:'/app/',那么整个项目的/肯定是是在app目录下
但在模板代码中怎么做才能在项目中转向到www网站根目录的index.html呢
网上搜索了好多,都找不到答案!