无法将参数类型URL分配给参数类型字符串

时间:2020-10-20 12:38:16

标签: typescript url types axios

我正在尝试使用URL类型执行Axios请求。但我收到错误>>> id 1 >>> 1 2 >>> 1 3 >>> 1 4 >>> id 2 >>> 2 1 >>> 2 3 >>> 2 4 >>> id 3 >>> 3 1 >>> 3 2 >>> 3 4 >>> id 4 >>> 4 1 >>> 4 2 >>> 4 3 >>> Adjacency matrix of the layer: >>> 0 0 0 0 0 0 0 1 1 1 0 1 0 1 1 0 1 1 0 1 0 1 1 1 0

const dispatch = useDispatch();

const layout = {
        labelCol: { span: 4 },
        wrapperCol: { span: 18 },
    };
const [form] = Form.useForm();

<Form {...layout} form={form}>
                    <Form.Item
                            label="Name"
                            name="Name"
                            rules={[{ required: true }]}
                    >
                        <Input
                            placeholder={"Please enter a name"}
                            value={name}
                            addonBefore={name}
                            onChange={(event) => dispatch({type: WIZARD_SET_NAME, name: event.target.value})}
                        />
                    </Form.Item>
</Form>

我应该如何使其起作用?我有半个想法将它放回字符串中,但是我感觉这是一个回归。

1 个答案:

答案 0 :(得分:0)

就像错误提示一样,您在预期URL的位置给出了string

如果由于某些原因要继续使用类型URL,则可以执行以下操作:将this.urlDevices.toString()作为axios.post()方法的第一个参数。

或者,如果您不打算使用urlDevices的静态方法,也可以只将string输入为URL