z***@gmail.com
z***@gmail.com
  • 发布:2021-01-04 09:55
  • 更新:2021-01-04 09:55
  • 阅读:417

【报Bug】新版开发工具不支持声明式渲染语句方法

分类:HBuilderX

产品分类: HbuilderX

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: 20H2

HBuilderX版本号: 3.0.4

App下载地址或H5⽹址: https://www.dcloud.io/hbuilderx.html

示例代码:

组件代码:


<view v-for="(i,idx) in taskList" :key="idx" class="item">  
<view class="date" v-if="showDate">{{i.starttime==taskList[idx-1].starttime?'':timeFormat(i.starttime)}}</view>  
</view>  
</template>  
<script>  
    export default {  
        props:{  
                     taskList:{  
                type:Array,  
                default:null  
            },  
},  
               methods:{  
                      timeFormat(val){  
                              //获取当前日期  
                              let date =new Date().toLocaleDateString().replace(/\//g,'-')  
                              return date==val.split(' ').splice(0,1)?'今天':val.split(' ').splice(0,1)  
                             }  
                  }  
}```  
组件引用:
```<template>  
<custom-mission :taskList="tasks" value="我要帮" showDate ></custom-mission>  
</template>  
<script>  
data() {  
            return {  
                tasks: [{  
                    starttime: '2020-12-24 17:00:00'  
                }]  

            }  
        }  
</scritp>```

操作步骤:

使用最新版开发工具编译到微信小程序开发工具

预期结果:

正常渲染

实际结果:

微信小程序开发工具报[Vue warn]: Error in render: "TypeError: Cannot read property 'starttime' of undefined"

found in

---> <CustomMission> at components/customMission.vue
pages/mine/browsingHistory.vue

bug描述:

使用最新版hbuildx
<view class="date" v-if="showDate">{{i.starttime==taskList[idx-1].starttime?'':timeFormat(i.starttime)}}</view>
组件加上timeFormat方法直接无法编译界面如图1
使用hbuildx v2.6.16可以正常编译(界面如图2)

2021-01-04 09:55 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复