5***@qq.com
5***@qq.com
  • 发布:2024-01-11 15:36
  • 更新:2024-01-11 16:40
  • 阅读:227

【报Bug】vue3 uniapp 动态拼接slot,h5模式正常,小程序报错

分类:uni-app

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Mac

PC开发环境操作系统版本号: macos14.2

HBuilderX类型: 正式

HBuilderX版本号: 3.99

第三方开发者工具版本号: 最新

基础库版本号: v3.3.1 (2024-01-03)

项目创建方式: HBuilderX

示例代码:
<template>    
  <view class="wrapper">    
    <demo :list="list">    
      <template v-for="(item,index) in list" v-slot:[`tab${index}`]> 11111111111111 </template>    
    </demo>    
  </view>    
</template>    

<script setup lang="ts">    
  import demo from '../../compontents/demo.vue';    
  import { ref } from 'vue';    

  const list = ref([    
    {    
      key: 'key1',    
      value: 'value1',    
    },    
    {    
      key: 'key2',    
      value: 'value2',    
    },    
    {    
      key: 'key3',    
      value: 'value3',    
    },    
    {    
      key: 'key4',    
      value: 'value4',    
    },    
    {    
      key: 'key5',    
      value: 'value5',    
    },    
  ]);    
</script>    

<style scoped>    
  .wrapper {    
    padding: 200rpx;    
    font-size: 32rpx;    
  }    
</style>    

组件

<template>    
  <view v-for="(item, index) in list" :key="index">    
    <slot :name="'tab'+index">{{ item }}</slot>    
  </view>    
</template>    

<script lang="ts">    
  import { defineComponent, PropType } from 'vue';    

  export default defineComponent({    
    props: {    
      list: {    
        type: Array as PropType<any[]>,    
        default: () => [],    
      },    
    },    
    setup() {    
      return {};    
    },    
  });    
</script>    

<style scoped></style>    

操作步骤:

h5运行正常、小程序运行报错

预期结果:

小程序正常渲染slot内容

实际结果:

报错ReferenceError: index is not defined

bug描述:

v-for动态slot 拼接name
图一 h5运行正常,图二 小程序运行后报错 ReferenceError: index is not defined

2024-01-11 15:36 负责人:HRK_01 分享
已邀请:
HRK_01

HRK_01

感谢反馈,接下里我将尝试验证并修复该bug

  • 5***@qq.com (作者)

    复现了吗 会修复吗

    2024-01-12 15:41

  • HRK_01

    回复 5***@qq.com: 复现了,感谢您的反馈,已加分。现正排查问题并尝试修复

    2024-01-12 15:50

要回复问题请先登录注册