react代码问题 ,第一次写react不知道哪里错了,打包的时候一直报错

来源:5-8 利用 Parcel 打包普通网站以及 React 架构网站的资源方案

慕粉3324955

2018-02-25

http://img.mukewang.com/szimg/5a9280e2000108b409020266.jpg

http://img.mukewang.com/szimg/5a9280e20001157113441132.jpg


写回答

3回答

NLuke

2018-02-25

你的state写错地方了,

class AppContainer extends React.Component {
    constructor() {
        super()
        this.state = {
            name: '案例'
        }
    }
    
    ...
    
    render() {
        ...
    }
}

这么写吧。

0
0

Scott

2018-02-25

写成这样报错么?


import React from 'react'
const App = ({ name }) => {
  return <div>{name}</div>
}
export default App



另外具体是报的什么错误啊


0
1
慕粉3324955
还是报错 没办法截图只能 studay/movie/parcel/es/index.js:16:9: Unexpected token (16:9) 14 | } 15 | > 16 | render { | ^ 17 | return 18 | } 19 | } npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! movie@1.0.0 build: `rm -rf parcel/dist && parcel build parcel/index.html --no-cache -d parcel/dist --public-url /dist/` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the movie@1.0.0 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in:
2018-02-26
共1条回复

慕粉3324955

提问者

2018-02-25

App组件那个错误改过了,但还是报错

0
0

Koa2框架从0开始构建预告片网站

Koa2+MongoDB+Parcel+Puppeteer+AntDesign快速搭建预告片网站

751 学习 · 362 问题

查看课程