reactjs - 如何删除输入字段的内容?
问题描述
<div className="pt-4">
<label
htmlFor="location"
className="block text-sm font-semibold text-gray-700"
>
Refferal *
</label>
<div className="relative text-gray-400 focus-within:text-gray-600">
<div className="pointer-events-none absolute inset-y-0 left-0 pl-3 flex items-center">
<SearchIcon className="h-5 w-5" aria-hidden="true" />
</div>
<input
id="search"
className="pl-10 p-2 border shadow-sm focus:ring-indigo-500 focus:border-indigo-500 focus:outline-none block w-full sm:text-sm border-gray-300 rounded-md"
placeholder="Search"
type="search"
name="refferal"
value={values.refferal || profile.refferal}
onChange={handleInputChange}
/>
</div>
</div>
我在我的反应组件中预填充了这个输入字段。虽然,我想在用户输入字段时更改字段内的数据,但是当用户尝试清空字段内的内容时。弹出预填充的数据。如何清空该字段以便用户可以相应地更新数据。?
解决方案
推荐阅读
- javascript - 为什么 javascript 函数在 html 参考中不起作用?
- scala - 为什么隐式参数与非隐式参数结合使用时不起作用
- typescript - 如何发布多个 .d.ts 文件
- wordpress - 在 woocommerce 中的 Myaccount 页面中仅允许名称字段中的字母
- python - 使用逗号时python中的语法错误
- laravel - Vue:数据表上的搜索过滤器
- python - 安装对象检测 API 时出错:ImportError: cannot import name 'Cycler'
- python - Slicing a range from a pandas dataframe column using loc
- c++ - 未在 C++ 中显示适当的输出
- java - 用 Java 中的相同消息替换 IBM MQ 消息负载并回复(无 JMS)