我在angular 2 app中的assets文件夹中有一些图像和样式表文件但是如何在主index.html文件中访问这些文件和图像?
我有InputField 组件,它接受各种道具,如类型、占位符、值等。我正在尝试使用InputField 组件创建一个表单。我可以轻松地从表单传递道具,但无法将输入值保存到我的状态中。这是我的代码。
输入字段.js
import React, { useState } from "react";
const InputField = ({ value, label, placeholder, type, onChange }) => {
const handleChange = (e) => {
const { value } = e.target;
onChange(value);
};
return (
<div className="form-group">
{label && <label htmlFor="input-field">{label}</label>}
<input
type={type}
value={value}
className="form-control"
placeholder={placeholder}
onChange={handleChange}
/>
</div>
);
};
export default InputField;
Run Code Online (Sandbox Code Playgroud)
添加产品表单.js
import React, { useState } from "react";
import { Form, Button } from "reactstrap";
import InputField from "../UI/InputField";
const AddProductForm = …Run Code Online (Sandbox Code Playgroud)