vue.js - 如何在 vuejs 中获取更新的 $refs
问题描述
变量更新后如何$refs
在 Vuejs 中更新?
当我更新this.wordList
时,我得到了旧词this.$refs.words
<div>
<div class="list-container">
<div ref='wordList' v-bind:style="wordListStyles" class="word-list">
<div
v-bind:class="{active: word.isActive, word: true, error: word.status === 2, success: word.status == 1 && !word.isActive}"
ref='words' v-for="word in wordList" v-bind:key="word.text"
>{{word.text}}</div>
</div>
</div>
我试图添加v-if
和重新创建这样的组件:
reset() {
this.showList = false;
this.showList = true;
}
但这并没有帮助,以及这个答案https://stackoverflow.com/a/50044476/1037613
我知道参考不是实时的,但我需要它来获得每个单词的最高位置
this.wordRef[this.wordCount].getBoundingClientRect().top;
解决方案
推荐阅读
- javascript - 在 json 中查找密钥
- azure-functions - 如何在 Azure 函数中使用带有 blob 绑定的动态连接字符串
- python - 如何产生一个列表以将值流式传输到烧瓶?
- android - Firebase 存储 OnSuccessListener 不起作用
- android - 为什么 customView 可以扩展 constraintLayout 但会膨胀线性布局
- ruby-on-rails - AASM 不会触发 ActiveRecord::Rollback
- c# - Castle Windsor 使用 RestSharp.RestClient 构造函数注册错误
- python - 将 numpy 数组作为灰度图像上传到 S3 存储桶
- python - Pandas Dataframes.to_csv 截断长值
- mysql - MySQL 5.5 上的递归数据