diff --git a/src/sidebar-item/index.js b/src/sidebar-item/index.js index 3874753b9..b5ba38a44 100644 --- a/src/sidebar-item/index.js +++ b/src/sidebar-item/index.js @@ -23,6 +23,7 @@ export default createComponent({ methods: { onClick() { this.$emit('click', this.index); + this.parent.$emit('input', this.index); this.parent.$emit('change', this.index); route(this.$router, this); } diff --git a/src/sidebar/README.md b/src/sidebar/README.md index bf06a753c..d246b50fa 100644 --- a/src/sidebar/README.md +++ b/src/sidebar/README.md @@ -13,14 +13,11 @@ Vue.use(SidebarItem); ### Basic Usage -Use `active-key` prop to set index of chosen item - ```html - + + + - - - ``` @@ -30,29 +27,33 @@ export default { return { activeKey: 0 }; - }, - - methods: { - onChange(key) { - this.activeKey = key; - } } }; ``` +### Show Badge + +```html + + + + + +``` + ## API ### Sidebar Props | Attribute | Description | Type | Default | |------|------|------|------| -| active-key | Index of chosen item | `String | Number` | `0` | +| v-model | Index of chosen item | `String | Number` | `0` | ### Sidebar Events | Event | Description | Arguments | |------|------|------| -| change | Triggered when item changed | key: index of current item | +| change | Triggered when item changed | index: index of current item | ### SidebarItem Props @@ -66,4 +67,4 @@ export default { | Event | Description | Arguments | |------|------|------| -| click | Triggered when click item | key: index of current item | +| click | Triggered when click item | index: index of current item | diff --git a/src/sidebar/README.zh-CN.md b/src/sidebar/README.zh-CN.md index 4a956886e..23305a193 100644 --- a/src/sidebar/README.zh-CN.md +++ b/src/sidebar/README.zh-CN.md @@ -13,10 +13,10 @@ Vue.use(SidebarItem); ### 基础用法 -通过在`van-sidebar`上设置`active-key`属性来控制选中项 +通过`v-model`绑定当前选中项的索引 ```html - + @@ -29,12 +29,6 @@ export default { return { activeKey: 0 }; - }, - - methods: { - onChange(key) { - this.activeKey = key; - } } }; ``` @@ -44,7 +38,7 @@ export default { 通过`info`属性设置徽标内容 ```html - + @@ -57,13 +51,13 @@ export default { | 参数 | 说明 | 类型 | 默认值 | 版本 | |------|------|------|------|------| -| active-key | 当前导航项的索引 | `String | Number` | `0` | - | +| v-model | 当前导航项的索引 | `String | Number` | `0` | 2.0.4 | ### Sidebar Events | 事件名 | 说明 | 回调参数 | |------|------|------| -| change | 切换当前导航项时触发 | key: 当前导航项的索引 | +| change | 切换导航项时触发 | index: 当前导航项的索引 | ### SidebarItem Props @@ -79,4 +73,4 @@ export default { | 事件名 | 说明 | 回调参数 | |------|------|------| -| click | 点击时触发 | key: 当前导航项的索引 | +| click | 点击时触发 | index: 当前导航项的索引 | diff --git a/src/sidebar/demo/index.vue b/src/sidebar/demo/index.vue index bdbb0a414..cb45be168 100644 --- a/src/sidebar/demo/index.vue +++ b/src/sidebar/demo/index.vue @@ -1,10 +1,7 @@