【发布时间】:2021-11-14 03:05:45
【问题描述】:
我有那些紫色线条(如下图所示)。
我做了一些条件渲染,我想知道是否可以删除所有那些紫色线条。
我听说删除所有 div 并添加 React.Fragments 可能会有所帮助,这是我迄今为止所做的。但问题仍然存在。
如果有人能说出问题出在哪里,我将不胜感激!
主视图/渲染 1
<div className="user-infos">
<h4><u> Parameters </u></h4>
{ (componentState == "edit") ?
<form >
<Render 3/>
</form>
: (componentState == "index") ?
<Render 2/>
: (componentState == "delete") ?
<React.Fragment>
<p> Are you sure you want to leave us ? </p>
<p> If yes, you have to type your email and press "confirm".</p>
<form>
<input type="text" />
<input type="submit" value="confirm email"/>
</form>
<span>
<button> Delete ur account</button>
<button> Cancel </button>
</span>
</React.Fragment>
: ""
}
</div>
渲染 2
return (
<React.Fragment>
<p> Username : John </p>
<p> Timezone : London </p>
<span>
<button> Edit Profile </button>
<button> Delete account </<button>>
</span>
</React.Fragment>
渲染 3
return (
<React.Fragment>
<label for="email"> Username :
<input type="text"/>
</label>
<label for="text"> Timezone :
<span>
<select
onChange={options}
<options>
</select>
</span>
</label>
<button type="submit"> Save Profile </button>
<button> Cancel </button>
</React.Fragment>
);
【问题讨论】:
-
你也可以添加你的 CSS 吗?