LOGO

Object Traversal

Edit

San provides san-for directive (abbreviated as s-for) to render a list from Array data. Then how to traverse and render Object data? Since san does not provide directives for Object traversal, you can make use of the computed property.

Usage

1
2
3
4
5
6
7
8
9
10
11
12
13
class MyComponent extends San.component {
static computed = {
list() {
let myObject = this.data.get('myObject');
return Object.keys(myObject).map(item => {
return {
key: item,
value: myObject[item]
}
});
}
};
}

Demo

See the Pen san-traverse-object by liuchaofan (@asd123freedom) on CodePen.