三元运算符中结果语句包含变量要如何处理?
发布于 6 年前 作者 chao18 3524 次浏览 来自 问答

<navigator url="{{item.type ==‘video’ ?  ‘…/video/index?video_id=item.id&video_name=item.title’ : ‘…/subject_detail/index?subject_id=item.id&subject_name=item.title’ }}"  class=“search-li” wx:for="{{search_result}}" wx:key=“id”>

如上:在页面的跳转链接的地址上用三元运算符进行判断,但是结果中如果包含变量不知道如何 写才能正确被解析。

4 回复

这样写不行,两个变量会变成字符串,不会解析成对应的数据

上面说的item.id和item.title是两个变量

没人吗?

这样应该没问题吧

回到顶部