我尝试在循环中有条件地将数据属性值添加到我的vue列表中,然后尝试以下
{{model.parent_id !== null ? model.parent_id : 0}}
但是在这种情况下,如果在html标记SELECT * FROM (
SELECT Person, CASE WHEN [Event A] = 'x' THEN 'Event A' END AS [Event] FROM EventAttendees
UNION
SELECT Person, CASE WHEN [Event B] = 'x' THEN 'Event B' END AS [Event] FROM EventAttendees
UNION
SELECT Person, CASE WHEN [Event C] = 'x' THEN 'Event C' END AS [Event] FROM EventAttendees
) AS EventAttendees
WHERE Event is not null
order by Person
之外转储,则列表不再渲染,而不是我看到正确的输出
答案 0 :(得分:2)
在此之前使用:
,我会创建一个像这样的计算属性。
computed: {
parentId() {
if (this.model.parent_id !== null)
return this.model.parent_id
return 0;
}
}
<ul :data-parent="parentId"></ul>
答案 1 :(得分:0)
正确的语法
<ul :data-parent="{{(model.parent_id !== null) ? model.parent_id : 0}}"></ul>