1. require黄线问题
配置:
File->Settings...->Lanaguages & Frameworks -> JavaScript -> Libraries -> Add...
按图2填写,点击ok,效果图3所示,点击ok即可。
2. 设置代码缩进
File -> Settings... -> Editor -> Code Style -> JavaScript,设置数据如下
3. 代码提示插件
ReactNative-LiveTemplate
file -> import settings -> ReactNative.jar
4. 设置JavaScript模板
File -> Settings... -> Editor -> File and Code Templates -> Files -> JavaScript File,设置模板内容为
import React, { PureComponent } from 'react';
import {
StyleSheet,
View
} from 'react-native';
/**
* @FileName: ${NAME}
* @Author: ${USER}
* @Date: ${DATE}
* @Description: ${CONTENT}
*/
class ${NAME} extends PureComponent {
render() {
return(
<View style={styles.container}>
</View>
)
}
}
/**
* 样式属性
*/
const styles = StyleSheet.create({
container: {
backgroundColor: '#DDD'
}
});
/**
* 导出当前Module
*/
module.exports = ${NAME};
5. 自定义注释
File -> Settings... -> Editor -> Live Templates -> JavaScript, 点击右侧加号,
/**
*
* @author mazaiting
*/
使用: Windows下Ctrl+J,调出快捷输入框,选择对应的即可