scrolllayer

解读鸿蒙源码: 鸿蒙“小程序”工作原理研究笔记

佐手、 提交于 2020-10-21 06:24:54
1. 介绍 自从微信小程序出现以来,各种“小程序”如雨后春笋一般出现。事实证明小程序这种开发方式非常好,鸿蒙 JS UI 框架采用类似的方式也是在意料之中的。 一个小程序(在鸿蒙 OS 中,也就是 Ability)由多个页面组成,每个页面由三部分组成: .hml 用来描述界面的元素 .css 用来描述界面的风格 .js 用来编写处理事件逻辑 我们来看个例子: index.hml <div class="container"> <text>{{count}}</text> <input if="{{count < 10}}"type="button" value="Inc" onclick="inc"/> <input if="{{count > 0}}" type="button" value="Dec" onclick="dec"/> </div> index.css .container { flex-direction: column; justify-content: center; align-items: center; left: 0px; top: 0px; width: 454px; height: 454px; } index.js export default { data: { count: 5 }, inc() { this.count++; }, dec