harmony 鸿蒙Version Compatibility Adaptation
Version Compatibility Adaptation
As you incorporate new features into service widgets of your applications, take measures to avoid abnormal display of these features on earlier versions. You can specify the minimum SDK version in the service widget project so that service widgets incorporating new features will not be installed on incompatible systems. You can also follow the instructions in this section to implement forward compatibility during your service widget development.
Configure forward compatibility in the JSON configuration file. Specifically, set the apiVersion attribute, which is at the same level as the data and actions fields in the service widget configuration file. The content defined in apiVersion overwrites the original content in data based on the current version information.
Example:
Assume that the JS service widget framework supports WebP image sources since API version 9. Then you can implement forward compatibility as follows:
<!-- xxx.hml -->
<div>
<image src="{{imageSrc}}" style="width: 100px;height: 100px;"></image>
</div>
JSON configuration file:
{
"data": {
"imageSrc": "defaultSrc.png"
},
"apiVersion": {
"9": {
"imageSrc": "newSrc.webp"
}
}
}
The JS service widget development framework selects the most appropriate data based on the application configuration and the current API version.
If the API version is 8 or earlier, the value of imageSrc is defaultSrc.png.
If the API version is 9, the value of imageSrc is newSrc.webp.
你可能感兴趣的鸿蒙文章
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦