ionic4 路由跳转、ionic4 路由跳转传值 NavController 返回上一页 、NavController 回到根
1、普通路由跳转
<ion-button [routerLink]="['/pinfo']">
跳转到详情
</ion-button>
<ion-header> <ion-toolbar>
<ion-buttons slot="start">
<ion-back-button defaultHref="/tabs/tab1" text="返回"></ion-back-button>
</ion-buttons>
<ion-title>pinfo</ion-title> </ion-toolbar>
</ion-header>
2、路由跳转传值
<ion-button [routerLink]="['/pinfo']" [queryParams]="{aid:'1234'}">
跳转到详情并传值
</ion-button>
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-pinfo',
templateUrl: './pinfo.page.html',
styleUrls: ['./pinfo.page.scss'],
})
export class PinfoPage implements OnInit {
constructor(public route:ActivatedRoute) {
}
ngOnInit() {
this.route.queryParams.subscribe((data)=>{ console.log(data);
}
}
3、NavController 返回上一页
Ionic4.x 中从 tabs 切换页面跳转到其他页面,使用 ion-back-button 返回的话,默认都会返回 到 tab1 页面。如果我们想从那个 tab 页面跳转过去就返回到指定的 tab 页面的话,这时候就 要用到 NavController 里面提到的 back 方法。
import { NavController } from '@ionic/angular';
constructor(public nav:NavController) {
}
this.nav.back();
this.nav.navigateBack('/tabs/tab3');
完整代码
<ion-header> <ion-toolbar>
<ion-buttons slot="start"> <ion-button (click)="goBack()">
<ion-icon slot="icon-only" name="arrow-back"></ion-icon> </ion-button>
</ion-buttons>
<ion-title>pinfo</ion-title> </ion-toolbar>
</ion-header>
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { NavController } from '@ionic/angular';
@Component({
selector: 'app-pinfo',
templateUrl: './pinfo.page.html',
styleUrls: ['./pinfo.page.scss'],
})
export class PinfoPage implements OnInit {
constructor(
public route:ActivatedRoute,public nav:NavController) { }
ngOnInit() {
this.route.queryParams.subscribe((data)=>{
console.log(data);
})
console.log(window.history); }
goBack(){
this.nav.navigateBack('/tabs/tab3');
}
}
4、NavController 回到根
import { NavController } from '@ionic/angular';
constructor(public nav:NavController) {
}
this.nav.navigateRoot('/tabs/tab3');
ionic4 路由跳转、ionic4 路由跳转传值 NavController 返回上一页 、NavController 回到根的更多相关文章
- js 实现返回上一页和刷新等页面跳转功能
原文 出处http://www.2cto.com/kf/201111/109821.html 1. Javascript 返回上一页history.go(-1), 返回两个页面: history.go ...
- js 页面之间的跳转、传参以及返回上一页
js实现html 页面之间的跳转传参以及返回上一页的相关知识点 一.页面之间的跳转传参 1.在页面之间跳转的方式有两种: window.location.href="test.html?nu ...
- js 返回上一页和刷新以及页面跳转
1. Javascript 返回上一页history.go(-1), 返回两个页面: history.go(-2); 2. history.back(). 3. window.history.forw ...
- Django----使用模板系统渲染博客页面、实现列表和详情页的跳转、前后跳转功能
.模板写法同Flask,可以参考之前的FLask-模板 .将之前的BootStrap静态页面中的数据使用模板写 <!DOCTYPE html> <html lang="en ...
- js页面跳转(含框架跳转)整理
js方式的页面跳转1.window.location.href方式 <script language="javascript" type="text/java ...
- vue 获取跳转上一页组件信息
项目中有一需求,需要根据不同的页面路径url跳转进行不同的操作,首先需要获得上一页面的url,利用 beforeRouteEnter 这个钩子中的from参数获得之前url的信息,然后给 next 传 ...
- js中实现页面跳转(返回前一页、后一页)
一:JS 重载页面,本地刷新,返回上一页 代码如下: <a href="javascript:history.go(-1)">返回上一页</a> <a ...
- vue路由的钩子函数和跳转
首页可以控制导航跳转,beforeEach,afterEach等,一般用于页面title的修改.一些需要登录才能调整页面的重定向功能. beforeEach主要有3个参数to,from,next. t ...
- Vue-router路由判断页面未登录跳转到登录页面
router.beforeEach((to, from, next) => { if (to.matched.some(record => record.meta.requireAuth) ...
随机推荐
- opencv摄像头读取图片
# 摄像头捕获图像或视频import numpy as np import cv2 # 创建相机的对象 cap = cv2.VideoCapture(0) while(True): # 读取相机所拍到 ...
- jdk、jre、jvm三者联系
JDK(Java Development Kit)是针对Java开发员的产品,是整个Java的核心,包括了Java运行环境JRE.Java工具和Java基础类库.Java Runtime Enviro ...
- Java - 框架之 SpringBoot 攻略day01
Spring-Boot 攻略 day01 spring-boot 一. 基本配置加运行 1. 导入配置文件(pom.xml 文件中) <parent> <gr ...
- Continuous Subarray Sum II
Description Given an circular integer array (the next element of the last element is the first eleme ...
- 肤浅的聊聊 TiDB 扫表算子, 扫索引算子, 合取范式(CNF), 析取范式(DNF), skyline pruning
这一章主要涉及TiDB如下的源码: 1. 扫表算子怎样转换为扫索引算子; 2. 怎样把Selection算子的过滤条件化简, 转为区间扫描; 假设我们有一个表: t1( id int primary ...
- C二维数组用指针地址遍历
#include <stdio.h> #include <stdlib.h> int main(){ int a = 100; void *p = &a; printf ...
- C程序的函数说明使用和特点说明第一节
一.函数的特点: 全部都是全部函数构成 面向过程的:是函数式语言 函数的调用 是按需调用 封装包含 二.程序中函数的作用: 可以使用函数使程序变的简短 和 清晰 提高代码重用性 提高开发效率 有利于程 ...
- Spring的Core模块
Core模块主要的功能是实现了反向控制IOC(Inversion of Control)与依赖注入DI(Dependency Injection).Bean配置以及加载.Core模块中有Beans.B ...
- leaflet地图框架
leaflet 中文API LeafLet js 官网:http://leafletjs.com/index.html LeafLet js 官网demo: http://leafletjs.com/ ...
- fluent-动网格-动态层
模型算例来源:http://blog.sina.com.cn/s/blog_599d8faa0100w4uj.html 原视频下载地址:http://yunpan.cn/cujM2FxLuGdLK ...