Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

steps 第一次可以打开第二次进入后空白 提示 Error: Expect END descriptor with depth 0 but get another #1336

Closed
yangnum opened this issue Feb 21, 2019 · 9 comments · Fixed by #1367
Assignees
Labels
Milestone

Comments

@yangnum
Copy link

yangnum commented Feb 21, 2019

steps 第一次可以打开第二次进入后空白 提示 Error: Expect END descriptor with depth 0 but get another

  • 设备: iphonex
  • ios 12.0.1
  • Vant Weapp 版本:0.5.4
    微信版本 7.0.3
    vant weapp 的小程序 打开也是一样的
@yangnum
Copy link
Author

yangnum commented Feb 21, 2019

问题在这句代码上

@yangnum
Copy link
Author

yangnum commented Feb 21, 2019

**<van-icon wx:else name="checked" color="{{ activeColor }}" custom-class="van-step__active" />**

@zhaohuaxiaoy
Copy link

同样的问题,请官方尽快修复

@809481244
Copy link

809481244 commented Feb 23, 2019

同样的问题,请官方尽快修复

  • 安卓
  • Vant Weapp 版本:0.5.4
  • 微信版本 7.0.3

@lesamly
Copy link

lesamly commented Feb 27, 2019

找到组件:steps/index.wxml
修改代码:
view class="van-step__circle" wx:if="{{ item.status !== 'process' }}" style="{{ item.status === 'finish' ? 'background-color: ' + activeColor : '' }}"
为:
view class="van-step__circle" wx:if="{{ index !== active }}" style="{{ item.status === 'finish' ? 'background-color: ' + activeColor : '' }}"

ps:搞不懂为什么status一定要换成设定为一个英文,既然是组件了,为什么不直接通过index 和 active 来判断,搞个英文干嘛的

@rex-zsd
Copy link
Collaborator

rex-zsd commented Feb 28, 2019

找到组件:steps/index.wxml
修改代码:
view class="van-step__circle" wx:if="{{ item.status !== 'process' }}" style="{{ item.status === 'finish' ? 'background-color: ' + activeColor : '' }}"
为:
view class="van-step__circle" wx:if="{{ index !== active }}" style="{{ item.status === 'finish' ? 'background-color: ' + activeColor : '' }}"

ps:搞不懂为什么status一定要换成设定为一个英文,既然是组件了,为什么不直接通过index 和 active 来判断,搞个英文干嘛的

这样改有效的话,应该是微信的问题,理论上 wx:if 并不限制内部比较参数的类型。

@lesamly
Copy link

lesamly commented Feb 28, 2019

找到组件:steps/index.wxml
修改代码:
view class="van-step__circle" wx:if="{{ item.status !== 'process' }}" style="{{ item.status === 'finish' ? 'background-color: ' + activeColor : '' }}"
为:
view class="van-step__circle" wx:if="{{ index !== active }}" style="{{ item.status === 'finish' ? 'background-color: ' + activeColor : '' }}"
ps:搞不懂为什么status一定要换成设定为一个英文,既然是组件了,为什么不直接通过index 和 active 来判断,搞个英文干嘛的

这样改有效的话,应该是微信的问题,理论上 wx:if 并不限制内部比较参数的类型。

这个ui 自带的 demo 也是有问题的,进去之后出来再进就是空白了,报那个错误

@rex-zsd
Copy link
Collaborator

rex-zsd commented Feb 28, 2019

ok,下版本做下兼容 🤔

@lesamly
Copy link

lesamly commented Feb 28, 2019

ok,下版本做下兼容 🤔

其实从优化来说,数值比较比字符串比较的效率要高点吧
他并非是类型的比较,并非是只能数字比较,你调用其他你不在组件里面动态改动的字段来比较的话,他是没问题的。
测试后可以知道,此问题是在基础库2.6.1才会发现,如果是之前的基础库是没问题的,
从另外一个角度可以知道
steps组件里面formatSteps这个方法中 step.status = _this.getStatus(index); 是改变对象的属性的,而该属性和页面的 wx:if关联,形成了一个双向绑定的过程,在改动过程中页面已经进行绑定,如果把这句语句去掉,页面是不会报错的,或者在
this.setData({
steps: steps
});

改成
this.setData({
steps: steps,
_steps: steps
});
然后页面渲染使用的是_steps这个对象去渲染(要先判断这个值是否存在 wx:if="{{__steps}}"),这样的话,页面是不会出问题的。

与其不停的改动属性值影响到页面渲染,不如直接通过
index !== active来进行判断

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants