useCallback,useMemo和useEffect之间的主要区别是什么。?。给出何时使用useCallback,useMemo和useEffect的示例。
我需要从 HTML 行中删除除 div 和 span 之外的所有标签。我怎样才能做到这一点 ?
例子
const str = "<div><p></p><span></span></div>";
remove(str)//<div><span></span></div>
Run Code Online (Sandbox Code Playgroud) 我有这样一个对象。
let Filus = {
male: {
hat: [1],
jacket: [2],
pants: [3],
shoes: [4],
suit: [5]
}
};
Run Code Online (Sandbox Code Playgroud)
我想从这个对象得到这个数组。
let Filus = [1,2,3,4,5];
Run Code Online (Sandbox Code Playgroud)
怎么做?
我有这个 setProd Hooks
export interface faceProduct {
readonly title: string;
readonly prodState: string;
readonly shipping: string;
readonly sold: string;
readonly alt: string;
readonly material: string;
readonly location: string;
readonly src: string[];
readonly color: string[];
readonly saiz: string[];
readonly price: string;
}
export interface faceProductList extends faceProduct {
readonly id: string;
readonly to: string;
}
const [prod, setProd] = useState<faceProductList>({});
Run Code Online (Sandbox Code Playgroud)
我希望初始值是一个空对象。但我得到错误..
const [prod, setProd] = useState<faceProductList>(Object);
Run Code Online (Sandbox Code Playgroud)
一切都与它相连的东西一起工作。
javascript ×2
reactjs ×2
arrays ×1
ecmascript-6 ×1
html ×1
object ×1
react-hooks ×1
regex ×1
typescript ×1