This repository has been archived on 2023-08-29. You can view files and clone it, but cannot push or open issues/pull-requests.
yutent
/
anot.js
Archived
1
0
Fork 0
anot.js/src/19-:data.js

20 lines
478 B
JavaScript

//兼容2种写法 :data-xx="yy", :data="{xx: yy}"
Anot.directive('data', {
priority: 100,
init: directives.attr.init,
update: function(val) {
var obj = val
if (typeof obj === 'object' && obj !== null) {
if (!Anot.isPlainObject(obj)) obj = val.$model
for (var i in obj) {
this.element.setAttribute('data-' + i, obj[i])
}
} else {
if (!this.param) return
this.element.setAttribute('data-' + this.param, obj)
}
}
})
Anot 是Anot not only templateEngine的缩写。 它是一款迷你,易用、高性能的前端MVVM框架, fork于avalon。进行了大量的重构,精简部分冗余的API, 同时针对组件拓展进行了优化。
JavaScript 100%