React Native语法错误:意外的令牌,预期}

问题描述 投票:8回答:3

一个错误Unexpected token, expected }突然出现没有明确的原因。

enter image description here

第136:7行就是主人所说的:{

const styles = StyleSheet.create({
	master: {
		flex: 1,
		justifyContent: 'center',
		flexDirection: 'row',
		alignItems: 'center',
		flexWrap: 'wrap'
	}
});

之前工作正常。我试过了:

rm -rf node_modules && npm install
npm start -- --reset-cache

其中任何一个都没有变化。

javascript ios node.js reactjs react-native
3个回答
8
投票

此错误是由于我的渲染方法中缺少</>


1
投票

在我的情况下错误是

意外的令牌,预期“,”

。原因是在样式表中,使用=代替:

color = colors.white而不是color: colors.white


0
投票

就我而言,ComponentDidUpdate是在render()方法之后。

© www.soinside.com 2019 - 2024. All rights reserved.