Skip to content

Commit

Permalink
解决tabs组件的render方法可能会执行多次的问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
lzcmaro committed May 20, 2017
1 parent 2c30179 commit 8b603e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "v-mui",
"version": "1.0.0-beta2",
"version": "1.0.0-beta3",
"description": "Mobile UI elements for Vue 2.0",
"main": "dist/vue-mui.js",
"scripts": {
Expand Down
7 changes: 4 additions & 3 deletions src/components/tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export default {
// 遍历child,如果存在slot="content"的分发内容,且当前activeKey===item.eventKey的话,把它添加到data.tabContent中
for (let item of child) {
if (item.eventKey && this.activeKey === item.eventKey && item.$slots.content) {
this.tabContent = item.$slots.content
// $slots.content 得到的是一个VNode数组,直接赋值给tabContent的话,会导致render()执行多次
// 所以这里只取$slots.content的第一个VNode
this.tabContent = item.$slots.content.pop()
return
}
}
Expand All @@ -42,8 +44,7 @@ export default {
this.updateTabContent()
},
render(h) {
// TODO: 这里每次更新tabContent,都会render两次,未知原因,待解决
console.log('tabs.render')
console.log('tabs.render', this.$el)
const props = {
class: {
'nav': true,
Expand Down

0 comments on commit 8b603e7

Please sign in to comment.