vue $forceUpdate()强制刷新

摘要:
immediate-check="false">index)intabledata">{{item.component}}<divclass="cell">{{item.port}}<开启<{{item.script}}<span>{{item.logpath}}<spanv-if="arrowlist[index]">

改变列表的值 一直不渲染

        <van-pull-refresh v-model="refreshing" @refresh="onRefresh">

            <van-list
                    v-model="loading"
                    :finished="finished"
                    finished-text="没有更多了"
                    @load="onLoad"
                    :offset="10"
                    :immediate-check="false"
            >

                <div   v-for="(item,index) in tabledata">
                    <div class="cell"><span>组件名称:</span>{{item.component}}</div>
                    <div class="cell"><span>实例名称:</span>{{item.instance_name}}</div>
                    <div class="cell"><span>实例IP:</span>{{item.ip}}</div>
                    <div class="cell"><span>实例端口:</span>{{item.port}}</div>
                    <div   v-if="arrowlist[index]===false" @click="changeArrow(index)">
                        <span>
                            <span style="float: left">...</span><van-icon name="arrow-down"/>
                        </span>
                    </div>

                    <div   v-if="arrowlist[index]"><span>远程启停:</span>
                        <van-tag type="success" v-if="item.is_container">开启</van-tag>
                        <van-tag type="danger" v-else>关闭</van-tag>
                    </div>
                    <div   v-if="arrowlist[index]"><span>启停脚本:</span>{{item.script}}</div>
                    <div   v-if="arrowlist[index]"><span>日志路径:</span>{{item.logpath}}</div>
                    <div   v-if="arrowlist[index]"
                         @click="changeArrow(index)">
                        <span v-if="arrowlist[index]"><van-icon name="arrow-up"/></span>
                    </div>
                </div>

            </van-list>
        </van-pull-refresh>
 changeArrow(index) {
        this.arrowlist[index] = !this.arrowlist[index]
        this.$forceUpdate()
      },
      onSearch() {
        this.pageHelper.pageNo = 1
        this.loading = true
        this.tabledata = []
        this.fetchData()
        this.refreshing = false
      },
      fetchData() {
        const space = this.pageHelper
        space['search'] = this.search
        Api.QueryData(space).then(response => {
          const data = response.data
          this.totalSize = response.recordsTotal
          this.loading = false;
          if (data.length < this.pageHelper.pageSize || data.length === 0) {
            // 数据小于10条,已全部加载完毕finished设置为true
            this.finished = true;
          }
          this.tabledata = this.tabledata.concat(data)
          this.arrowlist = this.tabledata.map(() => false)
          console.log(this.arrowlist.length)
        })
      },

后来   ,发现加上强刷就好了

this.$forceUpdate()



vue强制更新$forceUpdate()

添加this.$forceUpdate();进行强制渲染,效果实现。搜索资料得出结果:因为数据层次太多,render函数没有自动更新,需手动强制刷新。

调用强制更新方法this.$forceUpdate()会更新视图和数据,触发updated生命周期。

免责声明:文章转载自《vue $forceUpdate()强制刷新》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇重定向Console输出到文本框JS倒计时,不会重复执行下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

在package.json里面的script设置环境变量,区分开发及生产环境。注意mac与windows的设置方式不一样

在package.json里面的script设置环境变量,区分开发及生产环境。 注意mac与windows的设置方式不一样。 "scripts": { "publish-mac": "export NODE_ENV=prod&&webpack -p --progress --colors", "publish-win":...

在SpringBoot自动配置的ObjectMappe基础上增加对空值处理,null转空串"",List、Array转[],Int转0

在SpringBoot自动配置的ObjectMappe基础上增加对空值处理,null转空串"",List、Array转[],Int转0;同时保证SpringBoot自动加载的配置不丢失;网上的一些教程照着改后都是把默认的ObjectMapper配置搞丢,导致我之前配置时间格式,Long精度都时效了,故通过分析产生以下处理方式: 1.自定义Null序列器;我...

IntelliJ IDEA 版本控制(svn、git) 修改文件后,所属目录的颜色也变化

IntelliJ IDEA 的版本控制默认文件修改了,所属目录的颜色是不会变化,这很不方便。如: 修改方法如下: File --> settings --> version control --> 勾选 "show directories with changed descendants" 改了之后效果如下:...

Python爬虫利器二之Beautiful Soup的用法

上一节我们介绍了正则表达式,它的内容其实还是蛮多的,如果一个正则匹配稍有差池,那可能程序就处在永久的循环之中,而且有的小伙伴们也对写正则表达式的写法用得不熟练,没关系,我们还有一个更强大的工具,叫Beautiful Soup,有了它我们可以很方便地提取出HTML或XML标签中的内容,实在是方便,这一节就让我们一起来感受一下Beautiful Soup的强大...

vue video.js使用技巧

1 初始化 Video.js初始化有两种方式。 1.1 标签方式 一种是在<video>标签里面加上class="video-js"和data-setup='{}'属性。 注意,两者缺一不可。 刚开始的时候我觉得后面的值为空对象{},不放也行, 导致播放器加载不出来,后来加上来就可以了。 1.2 JS方式 另外一种初始化 video.js 的方...

C#使用zookeeper

C#使用zookeeper https://blog.csdn.net/XuWei_XuWei/article/details/80611659 1.简述 zookeeper适用于分布式锁,配置管理,服务器管理,服务发现场景c#使用zookeeper基于开源组件ZooKeeperNetEx,详情GitHub搜一下 2.安装开发包 使用nuget安装ZooK...