我有一个Vuetify botnav;每个项目都在某个路由器路径下激活,我想在另一个路径下将其禁用。
当我想取消激活选项卡时,我尝试将@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON})
@Stateless
public class ServiceEJB {
@Context
HttpServletRequest httpRequest;
@Inject
private BusinessEJB bean;
private String userId;
@Path("someurl")
public Response someMethod1() {
final HttpSession session = httpRequest.getSession();
// get the userId from the session
String s = bean.someMethod2();
// return Response
}
}
@Stateless
public class BusinessEJB {
private String userId;
public String someMethod2() {
// .... log an entry with userId
return "something";
}
}
设置为-1,如果我从不激活botnav中的任何项目,这将起作用,但是如果我激活了一个项目,则设置active.sync =-再次点击1,它将自动激活第一项:
active.sync
在脚本中:
<v-bottom-nav
:active.sync="bottomNav"
:value="true"
shift
absolute
>
<v-btn
color="teal"
flat
value="recent"
>
<span>Recent</span>
<v-icon>history</v-icon>
</v-btn>
<v-btn
color="teal"
flat
value="favorites"
>
<span>Favorites</span>
<v-icon>favorite</v-icon>
</v-btn>
<v-btn
color="teal"
flat
value="nearby"
>
<span>Nearby</span>
<v-icon>place</v-icon>
</v-btn>
</v-bottom-nav>
我确实找到了一种可行的解决方案,方法是在botnav中设置一个虚拟的隐藏项目并将该项目的v-show设置为false,当我要停用所有项目时,我激活了该未显示的项目,结果我想要什么:
虚拟物品:
watch:{
$route:function(to, from){
switch(to.path){
case "/0":
this.bottomNav=0;
break
case "/1":
this.bottomNav=1;
break
case "/2":
this.bottomNav=2;
break
default: this.bottomNav=-1
}
}
}
并且每当我要停用脚本中的所有项目时,请执行以下操作:
<v-bottom-nav
:active.sync="bottomNav"
//more stuff
>
//other items
<v-btn v-show="0" value="inactivate"></v-btn>
</v-bottom-nav>
这种方法,但是有点荒唐,有没有更正式/优雅的方法来做到这一点?
答案 0 :(得分:1)