Skip to content

Commit b27cec7

Browse files
优化组件属性面板示例
1 parent b7168c7 commit b27cec7

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

examples/component/components_attribute_panel_vue.html

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<sm-web-map server-url="https://iportal.supermap.io/iportal" map-id="801571284" @load="mapLoad">
4646
</sm-web-map>
4747
<div class="panel-wrapper">
48-
<sm-attribute-panel :attributes="attrbiutes" :columns="tableColumns" :title="panelTitle">
48+
<sm-attribute-panel :attributes="attrbiutes" :value-render="customValueRender" :title="panelTitle">
4949
</sm-attribute-panel>
5050
</div>
5151
</div>
@@ -65,15 +65,6 @@
6565
computed: {
6666
panelTitle() {
6767
return this.title || resources.text_attributePanel
68-
},
69-
tableColumns() {
70-
return [{
71-
dataIndex: 'attribute'
72-
},
73-
{
74-
dataIndex: 'attributeValue'
75-
}
76-
];
7768
}
7869
},
7970
methods: {
@@ -91,10 +82,11 @@
9182
vm.title = matchFature.layer.id;
9283
vm.attrbiutes = Object.keys(matchFature.properties).map(function (prop) {
9384
return {
94-
attribute: prop,
95-
attributeValue: matchFature.properties[prop]
85+
title: prop,
86+
value: matchFature.properties[prop]
9687
}
9788
});
89+
vm.attrbiutes = vm.attrbiutes.slice(4);
9890
vm.addHighlightLayer(matchFature);
9991
} else {
10092
vm.attrbiutes = [];
@@ -133,6 +125,12 @@
133125
if (this.map.getLayer('highlight')) {
134126
this.map.removeLayer('highlight');
135127
}
128+
},
129+
customValueRender(text, record, index) {
130+
if (index === 3) {
131+
return '第 ' + record.value + ' 名';
132+
}
133+
return record.value;
136134
}
137135
}
138136
});

0 commit comments

Comments
 (0)