0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示

OpenHarmony原子化服务开发快速入门体验(中)

鸿蒙时代 来源:鸿蒙时代 作者:鸿蒙时代 2022-06-21 11:11 次阅读

四、编写项目代码
1.新新建一个文件夹common->images将部分照片放在images目录下,作为项目背景图片进行引用。

OpenHarmony原子化服务开发快速入门体验(中)-开源基础软件社区

图6 照片目录

2.编写第一个页面。

hml:


了解更多

复制

css:

/* phone */
@media screen and (device-type: phone) {
    .container {
        width: 100%;
        height: 100%;
        background-image: url("/common/images/zhishi.jpg");
        background-position: center;
        background-repeat: no-repeat;
        background-size:720px;
        display: flex;
        justify-content: center;
        align-items: center;

    }
   .liaojie{

       text-color: black;
       background-color: yellow;
       width: 50%;
       height: 100px;
       text-align: center;
       font-size: 42px;
       border-radius: 45px;
       font-weight: 700;
   }
}

复制

点击屏幕右方按钮,打开预览器查看效果。

OpenHarmony原子化服务开发快速入门体验(中)-开源基础软件社区

效果如下所示:

OpenHarmony原子化服务开发快速入门体验(中)-开源基础软件社区

3.编写第二个页面。

Index页面在项目创建的时候,会自动创建,若需要更多的页面,需要进行新建一个页面目录。方法如下:单击pages目录,选择新建一个JS Page。

OpenHarmony原子化服务开发快速入门体验(中)-开源基础软件社区

图3 新建页面

新建玩page目录后,编写相关页面代码即可。

hml:


了解更多

复制

css:

/* 说明设备类型 */
@media screen and (device-type: phone) {/* 样式 */
.box {
width: 100%;
        height: 100%;
        background-image: url("/common/images/page2.jpg");
        background-size: 720px;
        display: flex;
        justify-content: center;
    }
    .liaojie1 {
        text-color: black;
        background-color: yellow;
        width: 30%;
        height: 50px;
        text-align: center;
    font-size: 22px;
        border-radius: 45px;
        font-weight: 700;
        margin-top: 70%;
    }
}


复制

效果如下:

OpenHarmony原子化服务开发快速入门体验(中)-开源基础软件社区

图2 效果图

在该页面采用了监听路由跳转的方式进行跳转到下一个页面。

4.编写第三个页面

hml:


{{know_interest}}

复制

css:

/* phone */
@media screen and (device-type: phone) {
    .box_interest {
        width: 100%;
        height: 100%;
        background-image: url("/common/images/xingq.jpg");
        background-position: center;
        background-repeat: no-repeat;
        background-size: 720px;
    }
    .button_interest {
        width: 100%;
        height: 150px;
        justify-content: center;
        margin-top: 320px;
    }
    .button_style_interest {
        width: 40%;
        height: 60px;
        text-align: center;
        font-size: 30px;
        border-radius: 45px;
        font-weight: 700;
        background-color: yellow;
        color: black;
       
    }
}

复制

js:

import router from '@system.router';

export default {
    data: {
        know_interest:"点击学习"
    },
    page_three(){
        router.push({
            uri:'pages/study/study'
        })
    }
}

复制

效果如下:

OpenHarmony原子化服务开发快速入门体验(中)-开源基础软件社区


图5 效果图

5.编写第四个页面

按照第二步的方法再新建一个页面。填写其页面代码。

hml:


    
{{$item}}
{{$item.id}}
{{show_text}}
{{know_study}}

复制

css:

/* phone */
@media screen and (device-type: phone) {
    .pagediv {
        width: 100%;
        height: 1500px;
        background-color: cornsilk;/**启用flex布局**/
        display: flex;/**布局方向为按列布局**/

        flex-direction: column;
    }
    .topdiv {
        width: 100%;
        height: 10%;
        background-color: #fad10a;/**启用flex布局**/
        display: flex;/**水平居中**/
        justify-content: center;/**垂直居中**/
        align-items: center;
        flex-direction: column;
    }
    .middlediv {
        width: 100%;
        height: 30%;
        background-color: antiquewhite;
        display: flex;
        justify-content: center;
        align-items: center;/**自动换行**/
        flex-wrap: wrap;
    }
    .box {
        width: 31%;
        height: 100px;
        background-color: #0373fc;
        border: 3px solid black;
        border-radius: 20px;
        margin: 5px;
        margin-top: 30px;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .textdiv {
        font-size: 30px;
        color: black;
        font-weight: bold;
    }
    .boxtxt {
        font-size: 45px;
        color: black;
        font-weight: bold;
    }
    .button_dj {
        background-color: #0373fc;
        text-color: white;
        height: 100px;
        width: 200px;
    }
    .bottomdiv{
        background-color: black;
        border: 2px solid black;
        width: 100;
        height: 400px;
        justify-content: center;
      

    }
    .div_dati {

        width: 90%;
        height: 300px;
        background-color: #0612f1;
        margin-top: 150px;
        margin-left: 40px;
        border:2px solid black;
        opacity: 1;
        display: flex;
        justify-content: center;

    }
    .text_style{
        color: white;
        font-size: 36px;
        opacity: 1;
        margin-left:10px;
        text-align: left;
    }
    .button_study {
        width: 100%;
        height: 150px;
        justify-content: center;
        margin-top: 40px;
    }
    .button_style_study {
        width: 35%;
        height: 70px;
        text-align: center;
        font-size: 22px;
        border-radius: 45px;
        background-color: yellow;
        color:black;
        font-weight: 400;
    }
}

复制

js:

export default {
    data: {
        title:["点击按钮","解锁术语解释与学习"],
        arrs:[
            {
                'id':'Ability',
                'value':'应用的重要组成部分,是应用所具备能力的抽象。Ability分为两种类型,Feature Ability和Particle Ability。'
            },
            {
                'id':'AbilitySlice',
                'value':'切片,是单个可视化界面及其交互逻辑的总和,是Feature Ability的组成单元。一个Feature Ability可以包含一组业务关系密切的可视化界面,每一个可视化界面对应一个AbilitySlice。'
            },
            {
                'id':'ANS',
                'value':'Advanced Notification Service,通知增强服务,是HarmonyOS中负责处理通知的订阅、发布和更新等操作的系统服务。'
            },
            {
                'id':'CES',
                'value':'Common Event Service,是HarmonyOS中负责处理公共事件的订阅、发布和退订的系统服务。'
            },
            {
                'id':'DV',
                'value':'Device Virtualization,设备虚拟化,通过虚拟化技术可以实现不同设备的能力和资源融合。'
            },
            {
                'id':'FA',
                'value':'Feature Ability,元程序,代表有界面的Ability,用于与用户进行交互。'
            },
            {
                'id':'HAP',
                'value':'HarmonyOS Ability Package,一个HAP文件包含应用的所有内容,由代码、资源、三方库及应用配置文件组成,其文件后缀名为.hap。'
            },
            {
                'id':'HDF',
                'value':'Hardware Driver Foundation,硬件驱动框架,用于提供统一外设访问能力和驱动开发、管理框架。'
            },
            {
                'id':'IDN',
                'value':'Intelligent Distributed Networking,是HarmonyOS特有的分布式组网能力单元。开发者可以通过IDN获取分布式网络内的设备列表和设备状态信息,以及注册分布式网络内设备的在网状态变化信息。'
            },
            {
                'id':'MSDP',
                'value':'Mobile Sensing Development Platform,移动感知平台。MSDP子系统提供两类核心能力:分布式融合感知和分布式设备虚拟化。'
            },
            {
                'id':'PA',
                'value':'Particle Ability,元服务,代表无界面的Ability,主要为Feature Ability提供支持,例如作为后台服务提供计算能力,或作为数据仓库提供数据访问能力。'
            },
            {
                'id':'Supervirtualdevice',
                'value':'超级虚拟终端亦称超级终端,通过分布式技术将多个终端的能力进行整合,存放在一个虚拟的硬件资源池里,根据业务需要统一管理和调度终端能力,来对外提供服务。'
            }
        ],
        show_text:'',
        know_study:"了解更多"
    },
    show(e){
        console.info(e)
        var list = this;
        this.arrs.forEach(element => {
            console.info(element.id)
            if (element.id==e) {
                list.show_text = element.value
            }
        });
        console.info(list.show_text);
    },
    page_four(){
        router.push({
            uri:'pages/harmonyos/harmonyos'
        })
    }
}

复制

效果如下:

OpenHarmony原子化服务开发快速入门体验(中)-开源基础软件社区

6.编写第五个页面

新建一个页面,用于介绍harmongy官方网站。代码如下

hml:


end.jpg

复制

css:

/* 说明设备类型 */
@media screen and (device-type: phone) {
    /*样式*/
    .container {
        flex-direction: column;
        height: 100%;
        width: 100%;
        background-image: url("/images/end.jpg");
    }
}

审核编辑:符乾江
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
  • 代码
    +关注

    关注

    30

    文章

    4555

    浏览量

    66736
  • OpenHarmony
    +关注

    关注

    23

    文章

    3262

    浏览量

    15159
收藏 人收藏

    评论

    相关推荐

    CW32快速开发入门

    CW32快速开发入门
    的头像 发表于 04-24 18:56 635次阅读
    CW32<b class='flag-5'>快速</b><b class='flag-5'>开发</b><b class='flag-5'>入门</b>

    【六】Purple Pi OH开发板带你7天入门OpenHarmony

    今天我们来从OpenHarmony简介、环境搭建、创建第一个OpenHarmony项目等方面开始OpenHarmony应用开发的第一步。一.Open
    的头像 发表于 03-14 08:31 134次阅读
    【六】Purple Pi OH<b class='flag-5'>开发</b>板带你7天<b class='flag-5'>入门</b><b class='flag-5'>OpenHarmony</b>!

    开放原子开源大赛—基于OpenHarmony的团结引擎应用开发赛正式启动!

    “基于OpenHarmony的团结引擎应用开发赛”是开放原子全球开源大赛下开设的新兴及应用赛的赛题之一,本次赛题旨在鼓励更多开发者基于OpenHar
    发表于 03-13 10:45

    基于DevEco Studio的OpenHarmony应用原子服务(元服务入门教程

    的DevEco StudioOpenHarmony项目在本目录下调整。将runtimeOS:””中间内容调为OpenHarmony即可。这种方式,不用开发板,通过预览器就可以查看项目
    发表于 11-06 11:18

    HarmonyOS鸿蒙原生应用开发设计- 元服务原子服务)图标

    HarmonyOS设计文档,为大家提供了独特的元服务图标,开发者可以根据需要直接引用。 开发者直接使用官方提供的元服务图标内容,既可以符合
    发表于 11-01 16:55

    新接触openharmony原子模块。

    看了很多文章,openharmony3.2支持arkts开发原子服务。但好像视频没有多少是关于Open
    发表于 10-20 11:29

    HarmonyOS/OpenHarmony原生应用开发-华为Serverless服务支持情况(四)

    /agc-cloudhosting-introductions-0000001057944575 三、Serverless模板 是基于Serverless服务构建的场景化解决方案,提供了应用生态常见场景的代码实现。开发者可将所需能力快速
    发表于 10-16 14:20

    HarmonyOS/OpenHarmony应用开发-DevEco Studio帮助快速入门的使用

    DevEco Studio内置有帮助中心,初学HarmonyOS 及OpenHarmony应用、元服务开发者,通过内置的帮助中去系统的学习相关内容,是边练边学,快速上手的最佳方式。
    发表于 09-13 16:28

    OpenHarmony轻量系统书籍推荐《OpenHarmony轻量设备开发理论与实战》

    开发的必备知识,是学习OpenHarmony轻量设备开发的必备书籍。 全书共分10章,包括OpenHarmony及其开发套件、搭建
    的头像 发表于 07-20 12:43 664次阅读

    高级开发套件快速入门指南

    高级开发套件快速入门指南
    发表于 07-03 20:20 0次下载
    高级<b class='flag-5'>开发</b>套件<b class='flag-5'>快速</b><b class='flag-5'>入门</b>指南

    OpenHarmony端云一体应用开发快速入门练习(下)登出销户等

    。 如果您是开发者,在您接入、使用认证服务SDK和服务前,我们要求您在隐私政策向用户告知我们SDK的名称、SDK提供方名称、收集个人信息类型、使用目的、隐私政策链接,并获取用户的同意
    发表于 06-21 14:17

    HarmonyOS元服务端云一体化开发快速入门(上)

    大小不能超过10MB。 三、配置工程信息 1.在工程配置界面,配置工程的基本信息。 点击“Next”,开始关联云开发资源。 *附件:HarmonyOS元服务端云一体化开发快速
    发表于 06-14 17:10

    开放原子开源基金会OpenHarmony开发者大会2023演讲资料汇总

    分享.pdf*附件:05-OpenHarmony全新依赖包管理系统与中心仓.pdf*附件:07-OpenHarmony应用测试服务探索与实践.pdf*附件:09-OH开发者大会-SIG
    发表于 05-29 16:34

    报名开启!开放原子开源大赛OpenHarmony创新赛来啦!

    大赛背景 开放原子开源大赛OpenHarmony创新赛期望达到以赛促用、以赛促教、以赛促学、以赛促练、以赛促创的效果,开发者通过学习OpenHarmony
    发表于 05-17 16:52

    OpenHarmony入门攻略:环境搭建

    此系列是笔者关于 OpenHarmony 智能家居开发套件(Hi3861 芯片)的学习历程,本篇作为入门环节,将具体介绍 OpenHarmony 的环境搭建。
    的头像 发表于 05-15 09:36 1639次阅读
    <b class='flag-5'>OpenHarmony</b><b class='flag-5'>入门</b>攻略:环境搭建