在使用iview的table组件时,要做排序

248 阅读1分钟

在使用iview的table组件时,要做排序
\

代码:

  {
                        title: "进货价",
                        key: "oriPrice",
                        minWidth: 130,
                        sortable: true,
                        align: "center",
                        render: (h, params) => {
                            return h('div', 
                               '¥'+params.row.oriPrice
                            )
                        },
                        sortMethod: (a, b, type) => {
                          if (type === 'desc') {
                            return parseInt(a) < parseInt(b) ? 1 : -1
                          } else {
                            return parseInt(a) > parseInt(b) ? 1 : -1
                          }                     
                        }
                    },

这里需要注意的是要返回1或者-1