My bootstrap-vue vue.js v2.6 app is receiving JSON data from a REST API. The data structure looks like this:
{
"fields": [
{
"key": "name",
"label": "name",
"sortable": true
},
{
"key": "item1",
"label": "item1",
"sortable": true
},
{
"key": "item2",
"label": "item2",
"sortable": true
},
{
"key": "item3",
"label": "item3",
"sortable": true
}
],
"items": [
{
"name": "Field name 1",
"item1": -0.05,
"item2": -0.06,
"item3": -0.07
},
{
"name": " Field name 2 "
"item1": -0.01,
"item2": -0.02,
"item3": -0.03
},
{
"name": "Field name 3",
"item1": -0.05,
"item2": -0.06,
"item3": -0.07
}
]
}
I want to add a formatter function to display the items in percentage format, specifically for item2.
{
"fields": [
{
"key": "name",
"label": "name",
"sortable": true
},
{
"key": "item1",
"label": "item1",
"sortable": true
},
{
"key": "item2",
"label": "item2",
"sortable": true,
"formatter": "value => { return (value + '%')}"
},
{
"key": "item3",
"label": "item3",
"sortable": true
}
],
"items": [
// Data remains the same
]
}
The Vue.js code I wrote for this purpose does not seem to work as expected. It's supposed to display item2 with a percentage sign added at the end but it doesn't. Any insight on what might be wrong would be appreciated.
I am using vue.js v2.6 and BootstrapVue.