如何在 POS 产品列表中对我的产品名称进行排序?这是我的代码,它说 names.sort() 不是函数。在js文件中
for(var i = 0, len = this.product_list.length; i < len; i++)
{
var product_node = this.render_product(this.product_list[i]);
var names = this.product_list[i].display_name
var sorted_names = names.sort();
console.log('Sorted Names',sorted_names)
}
做这样的事情,
var names=[];//array for names
for(var i = 0, len = this.product_list.length; i < len; i++)
{
var product_node = this.render_product(this.product_list[i]);
names.push(this.product_list[i].display_name);//push name in the array
}
names.sort();//sort names
console.log(names);//sorted array
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句