import React, { useState, useRef } from 'react'; import { Radio, Input } from 'antd'; import '../g.scss'; function UrlInput(props: IUrlInput) { const { change, value = { url: '', type: 'new' } } = props; const { url, type } = value; const [inputValue, setInputValue] = useState(url); //Input的value const [radioValue, setRadioValue] = useState(type); //Input的value const inputRef = useRef(null); const selectList = [ { value: 'new', label: '新页面跳转' }, { value: 'current', label: '当前页跳转' } ]; return (
setInputValue(e.target.value)} onBlur={(e) => change({ url: e.target.value, type: radioValue })} onPressEnter={() => { inputRef?.current?.blur(); }} />
{ setRadioValue(e.target.value); change?.({ url: inputValue, type: e.target.value }); }} value={radioValue} />
{radioValue === 'current' ? (

*当前页面跳转返回需点击浏览器后退按钮,建议选择新页面跳转。

) : ( <> )}
); } export default UrlInput; export interface IUrlInput { value: { url: string; type: string }; change: Function; } export interface NodeData { title: string; key: string | number; folderId?: string | number; selectable?: boolean; children?: NodeData[]; }