
React
Double__D
这个作者很懒,什么都没留下…
展开
-
React i18n 国际化 [TypeScript]
安装yarn add i18next react-i18next i18next-browser-languagedetector多语言文件zh-cn.json{ "home":"首页"}en-us.json{ "home":"Home"}i18n.tsximport i18n from "i18next";import LanguageDetector from 'i18next-browser-languagedetector';impo原创 2020-10-13 13:32:41 · 1277 阅读 · 0 评论 -
React js路由跳转 [TypeScript]
app.tsximport{withRouter}from'react-router'interface Props extends RouteComponentProps {}const App: React.FC<Props> = (props) => { function onOpen() { props.history.push("/") }}const Singer = withRouter(App as any);export...原创 2020-10-13 10:40:46 · 877 阅读 · 0 评论 -
React 防注入攻击 XSS攻击 (放心大胆的用吧)
consttitle=response.potentiallyMaliciousInput;//要接收到的可能含有危险内容的字符串放入大括号中,这是比较安全的做法constelement=<h1>{title}</h1>;React DOM在渲染之前默认会过滤所有传入的值。它可以确保应用不会被注入攻击。所有的内容在渲染之前都被转换成了字符串。这样可以有效地防止 XSS(跨站脚本攻击)。...原创 2020-10-12 23:56:27 · 3161 阅读 · 0 评论