当前位置:   article > 正文

鸿蒙js开发教程,js开发1 鸿蒙js开发下的页面布局页面

js鸿蒙程序开发

鸿蒙开发环境下有一下两个小点需要读者引起注意

1.布局的时候一定要启用flex按列布局(这里与微信小程序js开发有一定区别)如下图:

47dbbeff211d6738f40bb9ab10db5ad8.png

00c590d7d174204cb1b29cd8278b7a9b.png

2.2.鸿蒙布局中不能直接写值 必须用包裹住  而微信小程序则并不要求.

77fc80be99ad623192a8a2d242a4bd66.png完整过程如下:

1.在data中定义数据模型

data: {

dataarrs:["麒麟","鲲鹏","升腾","凌霄","玄机","紫薇","天市","太微","饕餮"]

}

2.在视图层渲染布局:

鸿蒙

弹性

布局

{{$item}}

{{"中华有为"}}

3.css弹性布局对样式的属性设置

.pageview{

width: 100%;

height: 100%;

background-color: cornflowerblue;

/**启用flex布局**/

display: flex;

/**方向按列**/

flex-direction: column;

}

.topview{

width: 100%;

height: 20%;

background-color: deepskyblue ;

display: flex;

/**垂直居中**/

align-items: center;

/**水平居中**/

justify-content: center;

}

.middleview{

width: 100%;

height: 70%;

background-color: cornflowerblue;

display: flex;

align-items: center;

justify-content: center;

}

.bottomview{

width: 100%;

height: 10%;

background-color: powderblue;

}

.topcell{

width: 30%;

height: 60%;

border: 5px solid black ;

margin: 6px;

border-radius: 10px;

display: flex;

align-items: center;

justify-content: center;

}

.txt{

font-size: 50px;

font-weight:bold;

}

.midbox{

width: 80%;

height: 70%;

/*8border:5px solid black;**/

display: flex;

justify-content: center;

align-items: center;

flex-wrap: wrap;

}

.gong{

width: 30%;

height: 30%;

border:4px solid black;

margin: 3px;

border-radius: 5px;

display: flex;

align-items: center;

justify-content: center;

}

.txt1{

font-size: 50px;

font-weight:bold;

}

.bottombox{

width: 100%;

height: 100%;

border:2px solid black;

display: flex;

align-items: center;

justify-content: center;

}

.txt2{  font-size: 50px;

font-weight:bold;

}

最终效果图如下:

0f21c90a4e2174895fb5ee932b1f4147.png

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/297546
推荐阅读
相关标签
  

闽ICP备14008679号