Expect END descriptor with depth 0 but g
发布于 5 年前 作者 zhangqiang 11659 次浏览 来自 问答

报错信息:

Expect END descriptor with depth 0 but get another

Expect START descriptor with depth 2 but get another

对应的报错代码:

toChangeTab:function(e){
       var _this = this;       
       var tabIndex = e.currentTarget.dataset.index;
       var tabs = _this.data.render.tabs;
       tabs.forEach(
           function (value,index){
               tabs[index].isSelected = tabIndex === index;
           }
       );
       if (tabs[tabIndex].tab_type != 'service') {
           _this.setData({
               'render.opacity': 1.0,    
           })
       } else{
           var opacityWelfareTab = _this.data.render.opacityWelfareTab
           _this.setData({
               'render.opacity': opacityWelfareTab,
           })
       }
       _this.setData({
           'render.tabs': tabs,
           'render.selectedTab': tabs[tabIndex],
       })
   },

更改后的代码:

toChangeTab:function(e){
       var _this = this;       
       var tabIndex = e.currentTarget.dataset.index;
       var tabs = _this.data.render.tabs;
       tabs.forEach(
           function (value,index){
               tabs[index].isSelected = tabIndex === index;
           }
       );
       if (tabs[tabIndex].tab_type != 'service') {
           _this.setData({
               'render.opacity': 1.0,
               'render.tabs': tabs,
               'render.selectedTab': tabs[tabIndex]
           })
       } else{
           var opacityWelfareTab = _this.data.render.opacityWelfareTab
           _this.setData({
               'render.opacity': opacityWelfareTab,
               'render.tabs': tabs,
               'render.selectedTab': tabs[tabIndex]
           })
       }
        
   },

实在不知道为什么这样改就对了。。。。。。

求解。

1 回复

用wx:for循环自定义组件也会出现,奇怪的是用wepy循环自定义组件却没有问题,此坑不知道怎么解

回到顶部