RawText " " must be wrapped in an explicit <Text> component

本文分享了一次解决React Native中RawText必须被显式的Text组件包裹的问题经历,并提供了正确的代码书写方式,强调了遵循代码风格的重要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天在写博客的时候,本来打算写一些学习的过程,现在19:00了,可是居然出现

RawText " " must be wrapped in an explicit <Text> component

这样的错误,由于初学,所有查找资料的时候,发现react-native也有如此严格的代码风格。


我的代码是这样写的:

 <View>       <Text>开发</Text></View>

亲们发现有什么问题吗?


报的错误就是这样的,


一开始没注意,可以后才把注意力放在“  ”上,也就是说“  ”出现了错误,仔细查找代码,发现代码风格一定要规范,这也是在学习react-native的时候,提前学习一下JavaScript的原因,可以不细究,但是基本语法一定要学。

修改:

如果View在同一行上,中间不要有空格

<View><Text>开发</Text></View>
如果不在同一行上
<View><Text>开发</Text>
</View>

这么写或者

<View>
<Text>开发</Text>
</View>
这样写都可以


明天把学习博客也补上






<?xml version="1.0" encoding="utf-8" ?> <Defs> <ThingDef Abstract="True" Name="MeleeWeaponUltratech" ParentName="BaseWeapon"> <techLevel>Ultra</techLevel> <statBases> <MarketValue>2000</MarketValue> <Mass>2</Mass> </statBases> <comps> <li> <compClass>CompQuality</compClass> </li> <li Class="CompProperties_Art"> <nameMaker>NamerArtWeaponMelee</nameMaker> <descriptionMaker>ArtDescription_WeaponMelee</descriptionMaker> <minQualityForArtistic>Excellent</minQualityForArtistic> </li> <li Class="CompProperties_Biocodable"/> </comps> <smeltable>true</smeltable> <burnableByRecipe>true</burnableByRecipe> <thingCategories> <li>WeaponsMelee</li> </thingCategories> <weaponTags> <li>UltratechMelee</li> </weaponTags> <tradeTags> <li>WeaponMelee</li> </tradeTags> <weaponClasses> <li>Melee</li> <li>Ultratech</li> </weaponClasses> <thingSetMakerTags> <li>RewardStandardMidFreq</li> </thingSetMakerTags> </ThingDef> <ThingDef ParentName="MeleeWeaponUltratech"> <defName>MeleeWeapon_PlasmaSword</defName> <label>plasmasword</label> <description>A metal-cored sword with a cutting edge. Plasma is wrapped around the core, held in place by an energy field. Targets are both sliced by the metal core, as well as burned or ignited by the plasma sheath.</description> <soundInteract>Interact_PlasmaSword</soundInteract> <meleeHitSound>MeleeHit_PlasmaSword</meleeHitSound> <equippedAngleOffset>-65</equippedAngleOffset> <relicChance>3</relicChance> <smeltable>false</smeltable> <weaponClasses> <li>MeleePiercer</li> </weaponClasses> <graphicData> <texPath>Things/Item/Equipment/WeaponMelee/PlasmaSword</texPath> <graphicClass>Graphic_Single</graphicClass> </graphicData> <tools> <li> <label>handle</label> <capacities> <li>Blunt</li> </capacities> <power>12</power> <cooldownTime>2</cooldownTime> </li> <li> <label>point</label> <capacities> <li>Stab</li> </capacities> <power>21</power> <cooldownTime>2.6</cooldownTime> <extraMeleeDamages> <li> <def>Flame</def> <amount>10</amount> <chance>0.5</chance> </li> </extraMeleeDamages> </li> <li> <label>edge</label> <capacities> <li>Cut</li> </capacities> <power>21</power> <cooldownTime>2.6</cooldownTime> <extraMeleeDamages> <li> <def>Flame</def> <amount>10</amount> <chance>0.5</chance> </li> </extraMeleeDamages> </li> </tools> </ThingDef> </Defs>逐行解释
最新发布
07-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值