小编Nic*_*her的帖子

带有 Vue 项目路由的 Azure 静态 Web 应用程序不起作用

我有一个使用 Azure 静态 Web 应用程序部署的 vue 项目。项目包含路由器(历史模式)功能。它在本地运行完美。但是在部署到 Azure 路径后,链接无法正常工作。例如,当我尝试从浏览器导航访问 mysite.com/about 时,它返回 404 错误。

公共文件夹中的 staticwebapp.config.json 文件:(我从 microsoft docs 中获取此示例)

{
    "routes": [
      {
        "route": "/*",
        "serve": "/index.html",
        "statusCode": 200
      }
    ]
  }
Run Code Online (Sandbox Code Playgroud)

我的路由器js文件:

import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  },
  {
    path: '/api',
    name: 'Api',
    component: () => …
Run Code Online (Sandbox Code Playgroud)

router azure vue.js vue-router azure-static-web-app

1
推荐指数
2
解决办法
449
查看次数

标签 统计

azure ×1

azure-static-web-app ×1

router ×1

vue-router ×1

vue.js ×1