首页 > 解决方案 > nuxt如何在页面名称后加问号

问题描述

我有这个设置:

pages/
--| search/
-----| _index.vue

我想要一个这样的网址:

myApp.com/search/?parameter=1

但是当我手动?parameter=1输入 url 后search它告诉我This page could not be found。我怎样才能实现路由,这样/我就可以?没有错误了?

标签: vue.jsnuxt.js

解决方案


这是一个干净的方法。

/pages/search-page.vue

<template>
  <div>This is the search page</div>
</template>

<script>
export default {
  name: 'SearchPage',
  mounted() {
    console.log('query >>', this.$route.query.search)
  },
}
</script>

推荐阅读