无法读取下一个AMP页面的未定义属性'amphtml'

时间:2019-06-14 15:42:09

标签: reactjs next.js

我正在使用Next.js 8.1函数在withAmp上创建APM页面。一切正常,

但是现在我将Next.js版本更新为金丝雀版本8.1.1-canary.52。 在当前的金丝雀版本中,withAmp替换为配置导出,如下所示。

export const config = {
    amp: 'hybrid'
};

但是这次我的项目给出了错误:

  

TypeError:无法读取未定义的属性'amphtml'       在Html.render(/Users/ravi/Workspace/NextJs/cashify-react-site/.next/server/static/XYWItbKuNuzVScPFeX8wV/pages/_document.js:1049:49)       在c(/Users/ravi/Workspace/NextJs/cashify-react-site/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:35:231)       在Sa(/Users/ravi/Workspace/NextJs/cashify-react-site/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:36:1)       在a.render(/Users/ravi/Workspace/NextJs/cashify-react-site/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:467)       在a.read(/Users/ravi/Workspace/NextJs/cashify-react-site/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:58)       在renderToString(/Users/ravi/Workspace/NextJs/cashify-react-site/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:53:83)       在渲染时(/Users/ravi/Workspace/NextJs/cashify-react-site/node_modules/next-server/dist/server/render.js:86:16)       在renderPage(/Users/ravi/Workspace/NextJs/cashify-react-site/node_modules/next-server/dist/server/render.js:236:20)       在_callee2 $(/Users/ravi/Workspace/NextJs/cashify-react-site/.next/server/static/XYWItbKuNuzVScPFeX8wV/pages/_document.js:994:24)       在tryCatch(/Users/ravi/Workspace/NextJs/cashify-react-site/node_modules/regenerator-runtime/runtime.js:45:40)

我的render文件的_app.tsx方法是:

render(){
    const {Component, pageProps} = this.props;
    const {loaded} = this.state;

    let isAmp = false;
    if (this.props.router.query) {
        isAmp = this.props.router.query.amp === '1';
    }

    if (isAmp) {
        return (
            <Html lang="en">
            <Component {...pageProps} />
            </Html>
        );
    } else {
        return (
            <Container>
                <ProgressBar loaded={loaded}/>
                <Component {...pageProps} />
            </Container>
        );
    }
}

0 个答案:

没有答案