mounted:
let data = [
{name:'y',SHARE_CHNG:2.45},
{name:'j',SHARE_CHNG:243},
{name:'f',SHARE_CHNG:42},
{name:'i',SHARE_CHNG:-42},
{name:'c',SHARE_CHNG:32},
{name:'0',SHARE_CHNG:102},
{name:'n',SHARE_CHNG:22},
];
console.log(this.getLowestPrice(data));
methods:
getLowestPrice(data) {
const lowPrice = Math.max.apply(
Math,
data.map(item => item.SHARE_CHNG)
);
return {
obj: JSON.parse(
JSON.stringify(data.find(item => lowPrice === item.SHARE_CHNG))
),
index: data.findIndex(item => lowPrice === item.SHARE_CHNG)
} },
运行结果: