Skip to content
目录

通用视图样式

所有视图组件都支持以下通用视图样式。

通用视图样式

属性名类型默认值说明示例
backgroundColorstring'#000000'背景色backgroundColor: '#FF0000' | '#FF000080' | 'linear-gradient(90deg #FF000080 #00FF0080)'
backgroundImagestring背景图片Image 组件src属性
boxSizingstring'none'盒模型模式boxSizing: 'none' | 'border-box'
borderStylestring'solid'四个边的边框类型borderStyle: 'none' | 'solid' | 'dashed' | 'dotted'
borderLeftStylestring'solid'左边框类型borderLeftStyle: 'none' | 'solid' | 'dashed' | 'dotted'
borderTopStylestring'solid'上边框类型borderTopStyle: 'none' | 'solid' | 'dashed' | 'dotted'
borderRightStylestring'solid'右边框类型borderRightStyle: 'none' | 'solid' | 'dashed' | 'dotted'
borderBottomStylestring'solid'下边框类型borderBottomStyle: 'none' | 'solid' | 'dashed' | 'dotted'
borderColorstring'#00000000'四个边的边框颜色borderColor: '#000000'
borderLeftColorstring'#00000000'左边框颜色borderLeftColor: '#000000'
borderTopColorstring'#00000000'上边框颜色borderTopColor: '#000000'
borderRightColorstring'#00000000'右边框颜色borderRightColor: '#000000'
borderBottomColorstring'#00000000'下边框颜色borderBottomColor: '#000000'
borderWidthnumber|string0四个边的边框宽度borderWidth: 10 | '10px'
borderLeftWidthnumber|string0左边框宽度borderLeftWidth: 10 | '10px'
borderTopWidthnumber|string0上边框宽度borderTopWidth: 10 | '10px'
borderRightWidthnumber|string0右边框宽度borderRightWidth: 10 | '10px'
borderBottomWidthnumber|string0下边框宽度borderBottomWidth: 10 | '10px'
borderRadiusnumber|string0四个角的边框圆角半径borderRadius: 10 | '10px'
borderTopLeftRadiusnumber|string0左上角边框圆角半径borderTopLeftRadius: 10 | '10px'
borderTopRightRadiusnumber|string0右上角边框圆角半径borderTopRightRadius: 10 | '10px'
borderBottomLeftRadiusnumber|string0左下角边框圆角半径borderBottomLeftRadius: 10 | '10px'
borderBottomRightRadiusnumber|string0右下角边框圆角半径borderBottomRightRadius: 10 | '10px'
shadowstring控件阴影(属性分别为:水平偏移量,垂直偏移量,模糊度,颜色)shadow: '5px 5px 10px #000000'
opacitynumber1透明度opacity: 0.5
visibilitystring'visible'控件是否显示('hidden'为不显示,但会参与布局)visibility: 'hidden' | 'visible'
zIndexnumber0控件z轴层级zIndex: 1
transformstring元素变换transform: 'translate(100,100),scale(0.5),rotateZ(30)'

INFO

动画(过渡效果)相关样式

属性名类型默认值说明示例
transitionPropertystring过渡效果的属性名称transitionProperty: 'transform, backgroundColor'
transitionDurationnumber0过渡效果持续时间(单位:秒)transitionDuration: '2, 2'
transitionDelaynumber0过渡效果延时时间(单位:秒)transitionDelay: 2
transitionTimingFunctionstring'ease'过渡效果的运动速率曲线transitionTimingFunction: 'linear'

linear: 线性运动
ease: 先加速后减速(结束时会特别慢)
ease-in: 加速运动
ease-out: 减速运动
ease-in-out: 先加速后减速

示例

js
let animView = new View(); 

// 设置style,指定transition过度动画属性 
animView.style = {
    width: 100,
    height: 100, 
    opacity: 0.5,
    backgroundColor: "#00ff00", 
    transitionDelay: 0.1, 
    transitionProperty: 'transform, backgroundColor, opacity',
    transitionDuration: '2, 3, 3', 
    transitionTimingFunction: 'ease-in',
 }; 
 
// 修改style,触发动画,因为transitionProperty没有指定width、height,所以width、height不会触发过度动画 
animView.style = {
    width: 50, 
    height: 50, 
    opacity: 1,
    backgroundColor: "#eb4034", 
    transform: 'translate(100,100), scale(0.5), rotateZ(30), skew(30,30)',
}