2018-08-04 16:26:50 +08:00
|
|
|
//样式定义 :css-width="200"
|
|
|
|
//:css="{width: 200}"
|
|
|
|
Anot.directive('css', {
|
|
|
|
init: directives.attr.init,
|
|
|
|
update: function(val) {
|
|
|
|
var $elem = Anot(this.element)
|
2019-07-16 11:45:23 +08:00
|
|
|
if (this.param) {
|
|
|
|
$elem.css(this.param, val)
|
|
|
|
} else {
|
|
|
|
if (typeof val !== 'object') {
|
|
|
|
return log(
|
|
|
|
':css指令格式错误 %c %s="%s"',
|
|
|
|
'color:#f00',
|
|
|
|
this.name,
|
|
|
|
this.expr
|
|
|
|
)
|
|
|
|
}
|
2018-08-04 16:26:50 +08:00
|
|
|
var obj = val
|
2019-07-16 11:45:23 +08:00
|
|
|
if (!Anot.isPlainObject(obj)) {
|
|
|
|
obj = val.$model
|
2018-08-04 16:26:50 +08:00
|
|
|
}
|
2019-07-16 11:45:23 +08:00
|
|
|
$elem.css(obj)
|
2018-08-04 16:26:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|