【问题标题】:Refreshing page while changing routes, Vue.js spring SPA更改路由时刷新页面,Vue.js spring SPA
【发布时间】:2021-11-09 00:53:30
【问题描述】:

我正在尝试使用 Vue.js 和 Spring boot 创建应用程序。使用 Vue 路由切换到不同的路由后,我的页面会重新加载。我正在使用这段代码转发到我的客户端路由。

@Controller
class FrontController {

    @GetMapping("/**/{path:[^\\.]*}")
    fun redirect(@PathVariable path: String): String {
        return "forward:/index.html"
    }
}

index.js

const routes = [
  {
    path: '/sad',
    name: 'AdminDashboard',
    component: AdminDashboard
  },
  {
    path: '/',
    name: 'UserList',
    component: UserList
  },
  {
    path: '/role/all',
    name: 'RoleList',
    component: RoleList
  },
  {
    path: '/course/all',
    name: 'CourseList',
    component: CourseList
  },
  {
    path: '/category/all',
    name: 'CategoryList',
    component: CategoryList
  }
]

const router = new VueRouter({
  mode: 'history',
  routes
})

export default router

这是显示我的问题的 gif:https://imgur.com/zv0CIzv。因此,我试图在打开不同页面时摆脱闪烁。它在 Microsoft Edge 上运行良好,但在 Chrome 和 Firefox 上运行良好。

【问题讨论】:

  • edit 描述您提出的问题或遇到的问题的标题。您当前的标题只不过是标签信息的重复。如果你删除了反刍的标签信息,你的整个标题就是 SPA。您的标题应该足够清晰和具有描述性,以便对正在浏览搜索结果列表并试图找到问题解决方案的未来网站用户有意义。谢谢。
  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: spring-boot vue.js kotlin


【解决方案1】:
fun redirect(@PathVariable path: String, e:event): String {
 e.preventDefault();
        return "forward:/index.html"
    }

【讨论】:

  • 对不起,它不起作用。它给了我:调用的方法 public abstract void org.w3c.dom.events.Event.preventDefault() is no accessor method!
猜你喜欢
  • 2014-08-28
  • 1970-01-01
  • 2021-11-19
  • 1970-01-01
  • 1970-01-01
  • 2022-01-05
  • 2019-08-16
  • 2019-05-15
  • 2016-06-15
相关资源
最近更新 更多