我是 React 新手,刚刚开始使用 Formik,我喜欢它使在 React 中制作表单和处理表单变得如此简单。我已经使用 formik 创建了多个自定义字段,我将我创建的反应选择字段作为示例放在这里。
import { ErrorMessage, Field } from "formik";
import React from "react";
import Select from 'react-select'
const SelectInput = (props) => {
const { label, name, id,options, required, ...rest } = props;
const defaultOptions = [
{label : `Select ${label}`,value : ''}
]
const selectedOptions = options ? [...defaultOptions,...options] : defaultOptions
return (
<div className="mt-3">
<label htmlFor={id ? id : name}>
{label} {required && <span className="text-rose-500">*</span>}
</label>
<Field
// className="w-full"
name={name}
id={id ? …Run Code Online (Sandbox Code Playgroud) 我对网络开发相当陌生,并没有过多考虑错误。但今天我注意到我必须使用一些东西json.stringyfy()来查看整个错误对象。另外,message语句 2 中未显示密钥,但当我打印时,error.message我收到一条消息而不是undefined. “message”甚至不是一个键(检查语句4),但仍然记录错误。message 记录一个值(typeof(error.message)is string)。
try {
//Some error occours
} catch (error) {
console.log(JSON.stringify(error)) //statement 1
console.error(error) //statement 2
console.log(error.message) //statement 3
console.log(Object.keys(error)) //statement 4
}
Run Code Online (Sandbox Code Playgroud)
语句1日志
MongoServerError: E11000 duplicate key error collection: trendyApp.Markets index: name_1 dup key: { name: "murat market" }
at D:\web projects\trendyApp\server\node_modules\mongodb\lib\operations\insert.js:51:33
at D:\web projects\trendyApp\server\node_modules\mongodb\lib\cmap\connection_pool.js:273:25
at handleOperationResult (D:\web projects\trendyApp\server\node_modules\mongodb\lib\sdam\server.js:363:9)
at MessageStream.messageHandler (D:\web projects\trendyApp\server\node_modules\mongodb\lib\cmap\connection.js:474:9)
at MessageStream.emit (events.js:375:28)
at processIncomingData (D:\web projects\trendyApp\server\node_modules\mongodb\lib\cmap\message_stream.js:108:16)
at MessageStream._write (D:\web …Run Code Online (Sandbox Code Playgroud) 我尝试删除 aria_log_control 文件
我尝试更改端口
我尝试删除 aria_log.0000001 文件
我尝试删除 aria_log_control 和 aria_log.0000001 文件
我以管理员身份运行控制面板
我也尝试多次重启电脑
就在一天前,它工作正常,尽管我不得不多次删除 aria_log_control 文件
。
InnoDB: using atomic writes.
2020-05-01 2:14:13 0 [Note] InnoDB: Mutexes and rw_locks use Windows interlocked functions
2020-05-01 2:14:13 0 [Note] InnoDB: Uses event mutexes
2020-05-01 2:14:13 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-05-01 2:14:13 0 [Note] InnoDB: Number of pools: 1
2020-05-01 2:14:13 0 [Note] InnoDB: Using SSE2 crc32 instructions
2020-05-01 2:14:13 0 [Note] InnoDB: Initializing buffer pool, total size …Run Code Online (Sandbox Code Playgroud) javascript ×2
express ×1
formik ×1
mongoose ×1
php ×1
react-select ×1
reactjs ×1
server ×1
web ×1
xampp ×1