Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

我的学习日志(十二) #14

Open
xxxgitone opened this issue Jul 6, 2017 · 0 comments
Open

我的学习日志(十二) #14

xxxgitone opened this issue Jul 6, 2017 · 0 comments

Comments

@xxxgitone
Copy link
Owner

  1. 当v-for和v-if一起使用的时候,v-for 的优先级比 v-if 更高,这意味着 v-if 将分别重复运行于每个 v-for 循环中,可以使用如下解决方案
<template v-if="shouldRenderTodos">
  <li v-for="todo in todos">
    {{ todo }}
  </li>
</template>
  1. 做聊天应用,每次发完消息,消息容器自动滚动到底部,可以使用watch监听数据的变化
 watch: {
    messages () {
      this.$nextTick(() => {
        const { chatMessage } = this.$refs
        chatMessage.scrollTop = chatMessage.scrollHeight
      })
    }
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant