方法一: 把navigator放在button外面
方法二:如果app的配置文件中的tabBar里有pagePath指向目标页面,navigator就不能正常运行,所以要删掉tabBar的内容
<navigator open-type="switchTab" url="{{isTeacher?'/pages/teacher/teacher':'/pages/index/index'}}" class=" login">
<van-button size='small' type="info" size="small" bind:click="login">
{{isTeacher?'教师登录':'学生登录'}}
</van-button>
</navigator>