基本React代码中的index.js导入错误

时间:2019-04-05 15:09:53

标签: javascript reactjs ecmascript-6 babel

'use strict'

import Title from './App'
import React from 'react'
import { render } from 'react-dom'

render(
  React.createElement(Title),
  document.querySelector('[data-js="app"]')
)

第3行出现错误

行:

import Title from './App'

错误:

Uncaught SyntaxError: Unexpected identifier in bundle.js:48

App.js

'use strict'

import React from 'react'

var Title = React.createClass({
  render: function () {
    return React.createElement('h1', null, 'Título')
  }
})

export default Title

括号显示此错误:

Expected an identifier and instead saw 'import'.import Title from './App'
ESLint (1): ERROR: Parsing error: The keyword 'import' is reserved                import Title from './App'

0 个答案:

没有答案