javascript - 在样式化组件的媒体查询中使用道具
问题描述
我有这段代码,我想在媒体查询后使用道具,请参见下面的代码。
export const Box = styled.div<IBox>`
position: relative;
min-height: 1px;
${({ column }) => FlexBasis(column)};
${({ display = "flex" }) => Display[display]};
margin: ${({ margin }) => margin};
padding: ${({ padding }) => padding};
/**
* This part below is the problem
* margin gives error as type any
/*
${media.mobile`
margin: ${({ margin }) => margin};
`};
}
我的问题是如何在媒体查询中使用道具。
解决方案
好吧,我刚刚发现这行得通,唯一的问题是必须一直重复它
/**
* This part below is the problem
* margin gives error as type any
/*
...其他代码
${media.mobile`
margin: ${({ margin }: IBox) => margin};
`};
推荐阅读
- javascript - 将此 .pop 方法调用到数组时,为什么会得到意外的 .length 结果
- laravel - 验证失败,即使它有值 Maatwebsite Laravel 验证
- azure - Azure 表单识别标签工具 Docker:未找到端点
- asp.net-core - 无法为 vs 2017 配置 iis express
- python-3.x - 使用 Outlook 桌面应用程序使用 Python 发送电子邮件 - 剪贴板作为电子邮件地址的输入
- vba - 命名工作簿
- python - 按使用 pymongo 创建的日期文档查询 mongoDB
- xml - XSLT for-each 无法提取值
- c++ - 如何从函数返回对象数组
- jquery - 导航页面时导航栏故障上的引导下拉图标