From 8575a088af85e100bb704c6d45402340a0262196 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Tue, 30 Apr 2019 13:58:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=90=9C=E7=B4=A2=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E6=8E=92=E5=BA=8F=E9=A1=BA=E5=BA=8F=20#86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/js/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/template/js/index.js b/template/js/index.js index cc97d5554a..f39d81d937 100644 --- a/template/js/index.js +++ b/template/js/index.js @@ -102,14 +102,15 @@ } } resultData.sort(function (a, b) { - // if (a.nIdx === -1 || b.nIdx === -1) { - // return 1; - // } return a.nIdx - b.nIdx }).sort(function(a, b) { return a.n.length - b.n.length; + }).sort(function (a, b) { + if (b.n.indexOf(self.query) < 0) { + return -1; + } + return a.n.indexOf(self.query) - b.n.indexOf(self.query); }); - console.log('resultData:', resultData) resultData = resultData.slice(0, show_list_count); for (i = 0; i < resultData.length; i++) {