我曾经使用 sublime text,但现在想使用atom.io 编辑器。我有这些代码行:
// error: Missing semicolon.
import React, { Component } from 'react'
export default class RegisterName extends Component {
constructor(props) {
// error: Missing semicolon.
super(props)
this.state = {
firstName: '',
lastName: '',
displayError: false,
error: 'Please provide a valid name'
//error: Missing semicolon.
}
}
// error: Class property must be methods. Expected '(' but saw instead '='....
next = () => {
console.log('next')
console.log(this.state.firstName, this.state.lastName)
}
render() {
return(
<View style={styles.container}>
<View>
<TouchableOpacity style={styles.logoContainer}>
<Icon name="md-analytics" size={60} color="#2ec76e" />
// error: Unclosed regular expression
</TouchableOpacity>
虽然这段代码运行良好。我在atom.io 编辑器中收到这些错误。我已经添加了.jshintrc
文件,包含以下几行:
{
"esnext": true
}
语法也设置为:Babel E6 Javascript
但即使这样也无济于事。我该如何消除这些错误?
在您的根目录中,添加一个新文件:
.jshintrc
添加以下代码并保存:
{
"esversion": 6
}
You can find the settings in using ctrl+, to open the settings and go to packages
=> linter-jshint
(or something like that) and find the pointer to the .jshintrc
file. If the file in your project structure differs, you can change that here.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)