文章预览
国际化是前端应用的常见需求,比如一个应用要同时支持中文和英文用户访问。 如果你在外企工作,那基本要天天做这件事情,比如我待过韩企和日企,我们的应用要支持韩文和英文,或者日文和英文。 那如何实现这种国际化的需求呢? 用 react-intl 这个包。 这个包周下载量很高: 我们来用一下。 创建个项目: npx create-vite 我们先安装 antd 来写个简单的页面: npm install npm install --save antd 去掉 main.tsx 里的 StrictMode 和 index.css 然后写下 App.tsx import React from 'react' ; import type { FormProps } from 'antd' ; import { Button, Checkbox, Form, Input } from 'antd' ; type FieldType = { username?: string; password?: string; remember?: string; }; const onFinish: FormProps [ 'onFinish' ] = ( values ) => { console .log( 'Success:' , values); }; const onFinishFailed: FormProps [ 'onFinishFa
………………………………