From 8a1a186dac11f1bf7e8e3018146dd3b2edfd0938 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 29 Jun 2019 11:48:56 +0800 Subject: [PATCH] [improvement] IndexBar: add class for active index (#3692) --- src/index-bar/index.js | 24 ++++++++++++------- .../test/__snapshots__/index.spec.js.snap | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/index-bar/index.js b/src/index-bar/index.js index 1d757851a..56ca725bb 100644 --- a/src/index-bar/index.js +++ b/src/index-bar/index.js @@ -152,6 +152,20 @@ export default createComponent({ }, render(h) { + const Indexes = this.indexList.map(index => { + const active = index === this.activeAnchorIndex; + + return ( + + {index} + + ); + }); + return (
- {this.indexList.map(index => ( - - {index} - - ))} + {Indexes}
{this.slots('default')}
diff --git a/src/index-bar/test/__snapshots__/index.spec.js.snap b/src/index-bar/test/__snapshots__/index.spec.js.snap index d18f1cdea..a186b4f79 100644 --- a/src/index-bar/test/__snapshots__/index.spec.js.snap +++ b/src/index-bar/test/__snapshots__/index.spec.js.snap @@ -32,7 +32,7 @@ exports[`scroll and update active anchor 1`] = ` exports[`scroll and update active anchor 2`] = `
-
ABCDEFGHIJKLMNOPQRSTUVWXYZ
+
ABCDEFGHIJKLMNOPQRSTUVWXYZ
1