ionic4 IonicPage 简单的路由模板(官方称为深层链接系统—— deep link system)

创建三个文件

html、ts、module.ts

html:对应内容为要跳转的页面的内容

ts:将@IonicPage装饰器添加到组件
module.ts:在IonicPageModule.forChild导入页面模块时添加深层链接的页面


示例:
       html:adv_plugin.html
              

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>

<div>
  <a href="javasrcipt:void(0);" onclick="top.location.href = '/#/adv-content';">
    <img src="http://img.zcool.cn/community/0117e2571b8b246ac72538120dd8a4.jpg@1280w_1l_2o_100sh.jpg"/>
  </a>
</div>
</body>

</html>

ts:adv_plugin.ts

import {IonicPage} from "ionic-angular";
import {Component} from "@angular/core";

@IonicPage({     //设置路由名称例:localhost:8100/#/adv-plugin   跳转 (注意需要加"/#/")
  name: 'adv-plugin',
  segment: 'adv-plugin'
})

@Component({
  templateUrl: 'adv_plugin.html' //对应页面
})
export class AdvPlugin {

}

 

module.ts:adv_plugin.module.ts

import {AdvPlugin} from "./adv_plugin";
import {IonicPageModule} from "ionic-angular";
import {NgModule} from "@angular/core";

@NgModule({      //把下面三个AdvPlugin改成ts中的class
  declarations: [
    AdvPlugin   //对应ts中的名称
  ],
  imports: [
    IonicPageModule.forChild(AdvPlugin)
  ],
  entryComponents: [
    AdvPlugin
  ]
})
export class AdvPlugineModule {
}

三个文件写完。。就可以愉快的链接了

localhost:8100/#/adv-plugin    (注意需要加"/#/")

最后发一下官方教程:
https://ionicframework.com/docs/api/navigation/IonicPage/

 

 

 

 

 

 

 

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值