风样的程序员React Native开发React Native开发经验集

React相关错误解决

2017-09-12  本文已影响50人  goodchax
ERROR in ./src/routes/ManagePage/routes/Department/components/AddDeptForm.js
Module build failed: SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag (44:14)

  42 |             })(
  43 |               <Input type="hidden" />
> 44 |               <Button>{parent.deptName}</Button>
     |               ^
  45 |             )}
  46 |           </FormItem>
  47 |         </div>

 @ ./src/routes/ManagePage/routes/Department/components/Department.js 63:19-43
 @ ./src/routes/ManagePage/routes/Department/index.js
 @ ./src/routes/ManagePage/index.js
 @ ./src/routes.js
 @ ./src/index.js
 @ multi webpack-hot-middleware/client?path=http://localhost:8041/__webpack_hmr&timeout=20000&reload=true ./src/index.js
错误:

Module build failed: SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag (44:14)

翻译:

模块构建失败:SyntaxError:相邻的JSX元素必须包装在封闭的标签中(44:14)

解决办法:(React规定必须拥有一个根节点,在外面用div包装)
<div>
<Input type="hidden" />
<Button>{parent.deptName}</Button>
</div>

后续继续添加


很高兴认识你,我们都一样,有过迷茫却从未放弃;害怕孤独可从不寂寞。

上一篇下一篇

猜你喜欢

热点阅读