先看下效果图
大致实现的功能点:
- 从Indext页面跳转到Second页面,传递两个参数,一个字符串,一个数量;
- Second获取Index页面传递的数据;
- Second页面点击返回弹窗;
- Second页面返回携带参数数据;
- Index获取Second页面回传数据。
下面我们一个一个讲解:
1、从Indext页面跳转到Second页面,并传递参数
import router from '@ohos.router';
@Entry
@Component
struct Index {
@State message: string = 'Index Page'
@State fromSecondMessage: string = ''
build() {
Column() {
Column() {
Text(`${this.message}`)
.width("300vp")
.height("60vp")
.textAlign(TextAlign.Center)
.fontSize("50fp")
.fontWeight(FontWeight.Normal)
Button("