当前位置: 首页 > news >正文

网站建设的创意淘宝网站建设的详细策划

网站建设的创意,淘宝网站建设的详细策划,兰溪做网站哪家好,电子商务网站策划 ppt效果展示 这篇博文在《鸿蒙:从0到“Hello Harmony”》基础上实现两个Page页面跳转 1.构建第一个页面 第一个页面就是“Hello Harmony”,把文件名和显示内容都改一下,改成“FirstPage”,再添加一个“Next”按钮。 Entry Compone…

效果展示

这篇博文在《鸿蒙:从0到“Hello Harmony”》基础上实现两个Page页面跳转

1.构建第一个页面

第一个页面就是“Hello Harmony”,把文件名和显示内容都改一下,改成“FirstPage”,再添加一个“Next”按钮。

@Entry
@Component
struct FristPage {@State message1: string = "FirstPage"@State message2: string = 'Next'build() {Row() {Column() {Text(this.message1).fontSize(30).fontWeight(FontWeight.Bold).height("10%").margin({top: 0})Button(this.message2).fontSize(30).fontWeight(FontWeight.Bold).height('5%').type(ButtonType.Capsule).margin({top: 30}).backgroundColor("#0D9FFB").width('50%').height('5%')}.width('100%')}.height('100%')}
}

在编辑窗口右上角的侧边工具栏,点击Previewer,打开预览器。第一个页面效果如下图所示:

2.构建第二个页面

1.在“entry > src > main > ets > pages”目录下,新建SecondPage.ets

同样,实现一个文本和一个Button按钮

@Entry
@Component
struct SecondPage {@State message1: string = 'SecondPage'@State message2: string = 'Back'build() {Row() {Column() {Text(this.message1).fontSize(30).fontWeight(FontWeight.Bold)Button(this.message2).fontSize(30).fontWeight(FontWeight.Bold).height('5%').type(ButtonType.Capsule).margin({top: 30}).backgroundColor("#0D9FFB").width('50%').height('5%')}.width('100%')}.height('100%')}
}

Previewer效果:

3.配置路由

配置第二个页面的路由。

在“Project”窗口,打开“entry > src > main > resources > base > profile”,

main_pages.json文件中的“src”下配置第二个页面的路由“pages/second”

代码如下:

{"src": ["pages/FirstPage","pages/SecondPage"]
}

4.实现页面跳转

​页面间的导航可以通过页面路由router来实现。

页面路由router根据页面url找到目标页面,从而实现跳转。

使用页面路由需要导入router模块。

(1).第一个页面跳转到第二个页面

在第一个页面中,跳转按钮绑定onClick事件,点击按钮时跳转到第二页。

FirstPage.ets”文件的代码如下:

// @ohos.router模块功能从API version 8开始支持,请使用对应匹配的SDK
import router from '@ohos.router';@Entry
@Component
struct FristPage {@State message1: string = "FirstPage"@State message2: string = 'Next'build() {Row() {Column() {Text(this.message1).fontSize(30).fontWeight(FontWeight.Bold).height("10%").margin({top: 0})Button(this.message2).fontSize(30).fontWeight(FontWeight.Bold).height('5%').type(ButtonType.Capsule).margin({top: 30}).backgroundColor("#0D9FFB").width('50%').height('5%').onClick(() => {console.info(`Succeeded in clicking the 'Next' button.`)try {router.pushUrl({ url: 'pages/SecondPage' })console.info('Succeeded in jumping to the second page.')} catch (err) {console.error(`Failed to jump to the second page.Code is ${err.code}, message is ${err.message}`)}})}.width('100%')}.height('100%')}
}

(1).第二个页面跳转到第一个页面

在第二个页面中,返回按钮绑定onClick事件,点击按钮时返回到第一页。

“SecondPage.ets”文件的示例如下:

import router from '@ohos.router';@Entry
@Component
struct SecondPage {@State message1: string = 'SecondPage'@State message2: string = 'Back'build() {Row() {Column() {Text(this.message1).fontSize(30).fontWeight(FontWeight.Bold)Button(this.message2).fontSize(30).fontWeight(FontWeight.Bold).height('5%').type(ButtonType.Capsule).margin({top: 30}).backgroundColor("#0D9FFB").width('50%').height('5%').onClick(() => {console.info(`Succeeded in clicking the 'Next' button.`)try {router.pushUrl({ url: 'pages/FirstPage' })console.info('Succeeded in jumping to the second page.')} catch (err) {console.error(`Failed to jump to the second page.Code is ${err.code}, message is ${err.message}`)}})}.width('100%')}.height('100%')}
}

5.实现效果

如开头展示

http://www.yayakq.cn/news/74874/

相关文章:

  • 打开网站wordpress常用数组
  • 西安网站建设小程序开发小程序模板做视频网站
  • 开发施工建设网站审核精准营销的案例
  • 网站建设及推广人员网站建设项目价格
  • 合肥公司建设网站首页上海中学官网登录
  • wordpress主题 relax网站手机优化
  • 企业网站建设的文章网站开发主要内容
  • 网站用什么布局wordpress在线不能播放视频播放器
  • 制作一个网站的流程有哪些论坛网站建设模板
  • 网站怎样做超链接c 语言网站建设
  • 网站建设延期合同书采用wordpress
  • 自己怎么开电商平台百度seo和谷歌seo有什么区别
  • 开发区网站制作公司蜘蛛抓取网站模块原理
  • 网站建设与管理复习题网站建设经营服务合同
  • 沈阳网站建设哪家好深圳建网站公司哪家好
  • 国外一直小猫做图标的网站wordpress 教垜
  • 现在用什么工具做网站好网站建设丶金手指花总14
  • 七冶建设集团网站受欢迎的句容网站建设
  • 公司企业网站搭建上海知名建站公司
  • 商丘做网站公司新站seo快速收录网站内容页优秀的产品设计与分析
  • 中国建设银行网站怎么改支付密码是什么用wordpress二级菜单导航
  • 山东建设厅官方网站临沂怎么给购物网站做推广
  • 网站开发找哪个网页怎么画
  • 外贸网站建设 福田建筑搜索网站
  • 电商网站建设会计分录苏州集团网站制作设计
  • 如何让google收录网站广州户外拓展训练基地
  • 如何进行网站设计信阳网
  • 漫画网站做任务给金币网站界面设计图片
  • 搜索网站老是跳出别的网站要怎么做做网站能赚钱吗知乎
  • 做两个一摸一样的网站桂林网站制作公司