Skip to content

[Dialog] 会影响响应式数据渲染 #3573

@lixl3345

Description

@lixl3345

tdesign-vue 版本

1.11.2

重现链接

No response

重现步骤

<template>
  <div class="processConfiguration">
    <t-button @click="add">刷新</t-button>
    <t-button @click="visible = true">弹窗</t-button>
    <!--    t-dialog 放这里不影响响应式 -->
    <template v-for="(item, index) in list">
      <div :key="index">
        {{ index }}
      </div>
    </template>
    <!--    t-dialog 放这里会影响响应式  调用add方法之后list未渲染,在之间插入其他元素 list响应式生效  -->
<!--    <div style="display: none"></div>-->
    <t-dialog :visible.sync="visible">
      <p>This is a dialog</p>
    </t-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [{}],
      visible: false,
    };
  },
  methods: {
    /** 添加 */
    add() {
      this.list = [...this.list, {}];
      this.$forceUpdate(); // 强制刷新组件树
    },
  },
};
</script>

期望结果

点击刷新按钮 list会重新渲染

实际结果

没有渲染、添加一个隐藏div 会渲染

框架版本

vue2.6 vite

浏览器版本

No response

系统版本

No response

Node版本

v18.20.4

补充说明

开发时候遇到。打包没测

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions