刷新calendarIndex页面时 出现tabbar默认选中首页的现象
正确情况应该是 对应 “我的”
解决方法:
mounted(){
let CURRENTHREF = this.$route.path;
if (CURRENTHREF.includes('/index')) {
this.active = 0
}else if(CURRENTHREF.includes('/calendarIndex')) {
this.active = 1
}
}
// includes() 方法用来判断一个数组是否包含一个指定的值,如果是返回 true,否则false。
let CURRENTLY = window.location.pathname
if (-1 !== CURRENTLY.indexOf('/index')) {
this.active = 0
} else if (-1 !== CURRENTLY.indexOf('/calendarIndex')) {
this.active = 1
}
//indexOf() 方法可返回某个指定的字符串值在字符串中首次出现的位置。(在字符串内进行检索)
//indexOf() 方法对大小写敏感!如果要检索的字符串值没有出现,则该方法返回 -1。
获取向前页面URL 的方法:( 完整URL:http://192.168.31.130:8085/home/signIn?openClassId=152#index)
- 完整URL : window.location.href // http://192.168.31.130:8085/home/signIn?openClassId=152#index
- 路由路径:this.$route.path // /signIn
- 路由路径参数 : this.$route.params
- 路由查询参数: this.$route.query // {openClassId: ‘152’}
- URL 的协议部分:window.location.protocol // http:
- URL 的主机部分: window.location.host //192.168.31.130:8085
- URL 的端口部分:window.location.port //8085
- URL 的路径部分(就是文件地址): window.location.pathname // /home/signIn
- 查询(参数)部分: window.location.search // ?openClassId=152
- 锚点:window.location.hash //#index 对用的内容