JS頁面跳轉的各種形式
阿新 • • 發佈:2018-12-13
-
普通跳轉頁面
const url = “/XXX/YYYYY/MMMMM”;
window.location.href = url ; -
普通跳轉開啟新頁面
const url = “/XXX/YYYYY/MMMMM”;
window.open(url, “_blank”, “”); -
vue頁面跳轉
// 字串
this.$router.push(’/home/first’)
// 物件
this.$router.push({ path: ‘/home/first’ })
// 命名的路由(可以傳遞引數)
this.$router.push({ name: ‘home’, params: { userId: wise }})
-
react頁面跳轉
第一種:
this.props.router.push(path)
第二種:
this.context.router.push(path)
如果需要傳遞引數:
this.props.router.push({ pathname : '/', state : { msg : 'you have logined and will redirect to your page'}}); this.context.router.push({ pathname : '/', state : { msg : 'you have logined and will redirect to your page'}});