【问题标题】:Unable to export path map with next js?无法使用下一个 js 导出路径图?
【发布时间】:2019-05-16 12:48:24
【问题描述】:

我正在尝试在我的下一个 js 项目中使用 ant design。我能够无缝地设计和开发所有东西,但是我在部署我的代码时遇到了问题,因为我无法导出。 以下是我要执行的脚本:-

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

// fix: prevents error when .css files are required by node
if (typeof require !== 'undefined') {
  require.extensions['.css'] = file => {}
}

module.exports = withCss(),{
    exportPathMap: function () {
      return {
        '/': { page: '/' },
        '/about': { page: '/about' },
        '/abc': { page: '/abc'},
        '/other': { page: '/other'},
        '/there': { page: '/there'},
        '/sample':{page:'/sample'},
        '/details':{page:'/details'}
      }
    }
  }

如果我运行 npm run next 或 npm run next build 一切正常,但如果我运行 npm run export 我在“next.config.js”中找不到“exportPathMap”。从“./pages”和 SyntaxError: Unexpected token {. 任何帮助或建议表示赞赏。谢谢。

【问题讨论】:

  • 我对 next.js 不熟悉,但在函数调用或数组之类的外部使用 , 似乎确实是语法错误..
  • @MoshFeu 感谢您的及时回复。您认为正确的方法应该是什么?
  • 根据我在那里找到的随机资源,该对象应该是withCss函数的参数。 spectrum.chat/next-js/general/…

标签: javascript reactjs web-deployment next.js antd


【解决方案1】:

你应该把所有东西都放到withCss

module.exports = withCss({
    exportPathMap: function() {
        return {
            '/': { page: '/' },
            '/about': { page: '/about' },
            '/abc': { page: '/abc' },
            '/other': { page: '/other' },
            '/there': { page: '/there' },
            '/sample': { page: '/sample' },
            '/details': { page: '/details' },
        };
    },
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-02
    • 2017-01-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多