当前位置: 首页 > news >正文

Material-UI使用

1、安装

npm install @mui/material @emotion/react @emotion/styled npm install @mui/x-data-grid

2、表格

使用DataGrid组件时,其模型中需要有属性id

有CheckBox时,使用onSelectionModelChange方法来监听选择的变化。返回的新选择模式是属性id

3、时间轴组件

需要安装@mui/lab

npm install @mui/lab

4、MUI System(v9.2)

4.1 styled方法

输入为tag, inputOptions = {}

  • tag
  • inputOptions

输出为函数muiStyledResolver,其输入为expressionsInput,返回值为Component

const muiStyledResolver = (...expressionsInput) => { const expressionsHead = []; const expressionsBody = expressionsInput.map(transformStyle); const expressionsTail = []; // Preprocess `props` to set the scoped theme value. // This must run before any other expression. expressionsHead.push(styleAttachTheme); if (componentName && overridesResolver) { expressionsTail.push(function styleThemeOverrides(props) { const theme = props.theme; const styleOverrides = theme.components?.[componentName]?.styleOverrides; if (!styleOverrides) { return null; } const resolvedStyleOverrides = {}; // TODO: v7 remove iteration and use `resolveStyleArg(styleOverrides[slot])` directly // eslint-disable-next-line guard-for-in for (const slotKey in styleOverrides) { resolvedStyleOverrides[slotKey] = processStyle( props, styleOverrides[slotKey], props.theme.modularCssLayers ? 'theme' : undefined, ); } return overridesResolver(props, resolvedStyleOverrides); }); } if (componentName && !skipVariantsResolver) { expressionsTail.push(function styleThemeVariants(props) { const theme = props.theme; const themeVariants = theme?.components?.[componentName]?.variants; if (!themeVariants) { return null; } return processStyleVariants( props, themeVariants, [], props.theme.modularCssLayers ? 'theme' : undefined, ); }); } if (!skipSx) { expressionsTail.push(styleFunctionSx); } // This function can be called as a tagged template, so the first argument would contain // CSS `string[]` values. if (Array.isArray(expressionsBody[0])) { const inputStrings = expressionsBody.shift(); // We need to add placeholders in the tagged template for the custom functions we have // possibly added (attachTheme, overrides, variants, and sx). const placeholdersHead = new Array(expressionsHead.length).fill(''); const placeholdersTail = new Array(expressionsTail.length).fill(''); let outputStrings; // prettier-ignore { outputStrings = [...placeholdersHead, ...inputStrings, ...placeholdersTail]; outputStrings.raw = [...placeholdersHead, ...inputStrings.raw, ...placeholdersTail]; } // The only case where we put something before `attachTheme` expressionsHead.unshift(outputStrings); } const expressions = [...expressionsHead, ...expressionsBody, ...expressionsTail]; const Component = defaultStyledResolver(...expressions); if (tag.muiName) { Component.muiName = tag.muiName; } if (process.env.NODE_ENV !== 'production') { Component.displayName = generateDisplayName(componentName, componentSlot, tag); } return Component; };

5、组件(v4)

5.1 Card卡片

集成内容和操作

  • CardContent
  • CardActions

参考资料:

安装 - MUI

GitHub - mui-org/material-ui at v5.1.0

http://www.jsqmd.com/news/1321873/

相关文章:

  • (2026年8月更新)洛阳甲醛检测公司怎么选:只做检测、不做治理的专业 CMA 资质实验室——醛清测研甲醛检测中心室内空气及环境检测 - 创达咨询
  • Android 中Dialog最佳实践
  • 宏、宏定义
  • 芯片OS测试:从稳定性到电源管理的量产关键验证
  • 漏洞挖掘高手的核心方法论与实战技巧
  • 千里求医路,重症病人高铁转运的平稳与温度 - AZJ888
  • NVIDIA GPU 与服务器型号匹配查询
  • TongRDS实战:从零构建MySQL高可用集群与读写分离架构
  • 字体设计如何助力读写障碍者:从原理到实践的包容性设计指南
  • Web漏洞扫描工具:核心价值与主流方案解析
  • WinBtrfs终极指南:3种方法在Windows上完美访问Linux Btrfs文件系统
  • 坚持减脂日程
  • 全国游客选潮汕地接 稻人旅行社护城河深厚领跑本地落地接待 - 互联网科技品牌测评
  • Java后端Base64图片压缩实战:BufferedImage与ImageIO应用详解
  • 【生成式AI数据管道设计禁区】:LLM微调元数据治理缺失导致的3次P0事故复盘
  • 2026 年 7 月新发布:邯郸口碑好的企业大门石牌坊生产厂家怎么联系,花百万做这门脸竟还踩坑?看完你再也不用交冤枉钱! - 行业推荐官[官方】--
  • 开源Godot 2D Builder:高效构建游戏场景的可视化工具
  • FreeIPA与Ambari集成实现企业级Kerberos认证
  • 北京产业园入驻流程哪家服务省心:【博亚信诚】一站式办 - 17328623207
  • 抖音下载工具的技术架构与异步任务调度实现
  • 免费自动抠图工具全搜罗:2026年网页、手机、电脑端实用方案汇总 - 耶斯去水印
  • 抖音无水印下载终极指南:5分钟掌握全平台内容保存技巧
  • UE5.5 VR项目UI开发:从交互原理到性能优化的实战指南
  • c++-对象模型
  • 2026 年至今,牡丹知名的匹布硅胶印花加工源头厂家哪家强,做印花的都在找它?居然能让匹布印花的质感和效率翻番!-德龙匹布印花 - 领域鉴赏官
  • BepInEx 6.0.0在Unity游戏中的稳定性问题深度解析与解决方案
  • 时序图实战指南:从核心原理到微服务交互设计
  • Unity游戏实时本地化实战:XUnity.AutoTranslator动态翻译方案详解
  • 游戏引擎与Heroic平台自动化集成:5个提升开发效率的实用技巧
  • Selenium无头浏览器自动化Web微信:配置、实战与工程化指南