如何组合多个内联样式对象? [英] How to combine multiple inline style objects?

查看:25
本文介绍了如何组合多个内联样式对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 React 中,您可以清楚地创建一个对象并将其指定为内联样式.即下面提到的.

In React you can clearly create an object and assign it as an inline style. i.e.. mentioned below.

var divStyle = {
  color: 'white',
  backgroundImage: 'url(' + imgUrl + ')',
  WebkitTransition: 'all', // note the capital 'W' here
  msTransition: 'all' // 'ms' is the only lowercase vendor prefix
};

var divStyle2 = {fontSize: '18px'};

React.render(<div style={divStyle}>Hello World!</div>, mountNode);

如何组合多个对象并将它们分配到一起?

How can I combine multiple objects and assign them together?

推荐答案

如果你使用 React Native,你可以使用数组表示法:

If you're using React Native, you can use the array notation:

<View style={[styles.base, styles.background]} />

查看我关于此的详细博文.

这篇关于如何组合多个内联样式对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆