() => {
if (global) {
return <span></span>
}
let inputRef
const storageRef = 'FOR_TEST'
const initStorage = Storage.getItem(storageRef)
const [content, setState] = useState(initStorage)
return (
<div>
<div>本地存储内容: {content + ''}</div>
<hr />
<input
className="form-control"
ref={e => (inputRef = e)}
style={{ width: 300 }}
defaultValue={content}
/>
<span
className="btn theme mr10"
onClick={e => {
setState(inputRef.value)
Storage.setItem(storageRef, inputRef.value)
}}
>
存储到本地
</span>
<span
className="btn red mr10"
onClick={e => {
Storage.setItem(storageRef, inputRef.value)
}}
>
获取储存的数据
</span>
</div>
)
}