next-定义路由

在next.config.js里写

const withCss = require('@zeit/next-css')

if(typeof require !== 'undefined'){
    require.extensions['.css']=file=>{}
}

module.exports = withCss({
  exportPathMap: async function (defaultPathMap) {
    return {
      '/login': { page: '/login/user' },
    }
  }
})

 

没有css的时候

// next.config.js
module.exports = {
  exportPathMap: async function (defaultPathMap) {
    return {
      '/': { page: '/' },
      '/about': { page: '/about' },
      '/readme.md': { page: '/readme' },
      '/p/hello-nextjs': { page: '/post', query: { title: 'hello-nextjs' } },
      '/p/learn-nextjs': { page: '/post', query: { title: 'learn-nextjs' } },
      '/p/deploy-nextjs': { page: '/post', query: { title: 'deploy-nextjs' } }
    }
  }
}

 

posted on 2020-09-02 17:09  秃了头也不退休  阅读(368)  评论(0编辑  收藏  举报

导航