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

门户网站的营销特点域名购买国外

门户网站的营销特点,域名购买国外,建设银行官方网站客户端,九江市区【关键字】 服务卡片、卡片跳转不同页面、卡片跳转页面携带参数 【写在前面】 本篇文章主要介绍开发服务卡片时,如何实现卡片点击跳转不同页面,并携带动态参数到js页面。在此篇文章“服务卡片 API6 JSUI跳转不同页面”中说明了如果跳转不同页面&#xf…

 【关键字】

服务卡片、卡片跳转不同页面、卡片跳转页面携带参数

【写在前面】

          本篇文章主要介绍开发服务卡片时,如何实现卡片点击跳转不同页面,并携带动态参数到js页面。在此篇文章“服务卡片 API6 JSUI跳转不同页面”中说明了如果跳转不同页面,这里在此基础上介绍跳转js页面时,如何携带参数到js页面中。

【开发步骤】

第一步:参考下方新建PageAbility继承AceAbility,在java目录下新建类型为Page的Ability如下:

cke_17713.png

cke_840.png

在config.json中ability字段中对新增的PageAbility配置如下:

{"name": "com.example.routeram.PageAbility","icon": "$media:icon","description": "$string:pageability_description","label": "$string:entry_PageAbility","type": "page","launchType": "standard"
}

第二步:在卡片的json文件中设置router事件,跳转到PageAbility中,参数中增加了一个type字段,后续可以通过type字段判断是跳转到哪个js page中;并定义title字段,将值设置为data中定义的动态参数,可以将其传到js page中。

{"data": {"detailTitle": "i am detail title","mineTitle": "i am mine title"},"actions": {"detailRouterEvent": {"action": "router","bundleName": "com.example.routeram","abilityName": "com.example.routeram.PageAbility","params": {"type": "detail","title": "{{detailType}}"}},"mineRouterEvent": {"action": "router","bundleName": "com.example.routeram","abilityName": "com.example.routeram.PageAbility","params": {"type": "mine","title": "{{mineTitle}}"}}}
}

同时,在index.json同级目录index.html文件中绑定mineRouterEvent和detailRouterEvent事件,如下所示:

<text class="title" onclick="detailRouterEvent">跳转detail</text>
<text class="title" onclick="mineRouterEvent">跳转mine</text>

第三步:在PageAbility的onStart方法中接收router 传过来的params(JSON格式),获取type字段进行跳转;获取title字段通过setPageParams方法传入到js page中。

    @Overridepublic void onStart(Intent intent) {IntentParams params = intent.getParams();if (params != null) {//获取routerEvent中的'params'String data = (String) params.getParam("params");if (!data.isEmpty()) {// 通过ZSONObject获取对应的"type"的值ZSONObject zsonObject = ZSONObject.stringToZSON(data);String type = zsonObject.getString("type");// 通过ZSONObject获取对应的"title"的值,并构造intentParams便于传入到js page中String title = zsonObject.getString("title");IntentParams intentParams = new IntentParams();intentParams.setParam("title", title);// setInstanceName对应的是Component Name一般我们把Js Page放在默认的default目录下,因此这边填写的是default;setInstanceName("default");// 跳转不同页面if (type.equals("detail")) {// 不需要传入参数写法:setPageParams("pages/detail/detail", null);// 可直接将卡片index.json中定义的参数直接透传到js page中:setPageParams("pages/detail/detail", params);// 此处将上面重新定义的intentParams传入js page中setPageParams("pages/detail/detail", intentParams);} else if (type.equals("mine")) {setPageParams("pages/mine/mine", intentParams);}}HiLog.info(TAG, "IntentParams: " + data);}super.onStart(intent);}

第四步:在detail.js和mine.js的data中定义相同名称的变量,此处定义title,即可接受到pageAbility中传入的title数据。

    data: {title: "",},onInit() {// 打印获取的title,并在index.html显示title值console.info("title is " + this.title)}

【最终效果】

a23480afde2d906dba767176e711aac9_442x927.gif%40900-0-90-f%20(1).gif

【服务卡片开发相关文档】

(3.0)服务卡片开发指导(包含基于JS UI和Java UI开发卡片):https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ability-service-widget-overview-0000001062607955

(3.0)Java服务卡片JS UI组件:https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-service-widget-file-0000001153028529

(3.1/4.0)FA模型服务卡片开发指导:https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/widget-development-fa-0000001427902244-V3

(3.1/4.0)Stage模型服务卡片开发指导:https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/service-widget-overview-0000001536226057-V3

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

相关文章:

  • 做网站如何在百度快照上排名wordpress 讲解
  • 怀化找工作网站郑州app外包公司
  • 自己做网站导航深圳招聘网最新招聘信息
  • 如何优化营销型企业网站平房装修设计图片大全 效果图
  • 建设wap手机网站制作晋城建设局官方网站
  • 合肥seo网站多少钱2024舆情信息最新热点
  • 企业网站需要什么功能西安网站seo推广厂家
  • 可以做英语阅读理解的网站1688网站
  • 布吉做棋牌网站建设怎样做有效的黄页网站
  • 网站模板制作视频教程wordpress 嵌套回复
  • 吉安微信网站anylink wordpress
  • 如何实现网站开发湖南系统建站怎么用
  • 实验楼编程网站百度风云榜小说排行榜历届榜单
  • 东莞网站策划如何调整网站板块位置
  • 福州网站大全排版网页设计教程
  • 贵州城乡住房建设厅网站泰州网站建设费用
  • 域名购买 网站建设为什么自己做的网站别人打不开
  • 赣州企业网站建设推广做国外网站建设
  • 经典软文案例分析优化排名推广关键词
  • 网站怎么自适应屏幕哪个网站可以专门做产品推广
  • 嘉兴做企业网站的公司网站建设费用预算模板
  • 洛阳网站建设手机设计图制作软件app免费
  • 怎么在百度上做自己的网站游戏开发和网站开发
  • 门户网站seo网站页脚模板
  • 吴江网站建设免费会员管理软件
  • 网站建设套模wordpress用什么编写的
  • 公司可以做网站吗南京做网站优化哪家好
  • 学校网站模板注意事项软件开发流程管理系统
  • 杭州上城区建设局网站深圳华强北二手手机
  • 山东济宁网站建设网站后台fpt