代码之家  ›  专栏  ›  技术社区  ›  user3142695

JS:Lint错误:意外标记=

  •  0
  • user3142695  · 技术社区  · 7 年前

    我得到一个标准的js lint错误

    /lib/with-apollo-client.js:7:24: Parsing error: Unexpected token =
    

    对于这个片段,它来自 https://github.com/zeit/next.js/blob/canary/examples/with-apollo/lib/with-apollo-client.js

    import initApollo from './init-apollo'
    import Head from 'next/head'
    import { getDataFromTree } from 'react-apollo'
    
    export default (App) => {
      return class Apollo extends React.Component {
        static displayName = 'withApollo(App)' // <-
        static async getInitialProps (ctx) {
        // ...
        }
      }
    }
    

    1 回复  |  直到 7 年前
        1
  •  0
  •   OliverRadini    7 年前

    我相信这是因为没有转换就不能用这种方式定义类属性:

    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes#Instance_properties

    推荐文章