我想根据 userId 是否为 null 来隐藏 div,我从函数中获取 userId。加载 html 后,我想根据条件隐藏一个 div。
render: function() {
userId = kf.helper.getUserId();
this.$el.html(this.template({}));
return this;
}
我在这里获取UserId
您正在获取 userId,检查它是否为 null 并通过模板调用发送参数。参数发送布尔值。然后在您的模板中进行条件渲染。如果参数为 true,则只需隐藏或显示您想要的 div。