>  기사  >  위챗 애플릿  >  미니 프로그램 개발 DEMO 사례

미니 프로그램 개발 DEMO 사례

Y2J
Y2J원래의
2017-05-11 13:22:202373검색

WeChat 미니 프로그램 레이아웃 예시:

다음 순서대로 소개합니다.

레이아웃 구현
로직 구현
스타일 구현

1. 레이아웃 구현

뷰 레이아웃에는 그림, 텍스트 설명, 정보 표시줄 및 구분선

<!--最外层-->
<view class="home-view1">
  <!--图片层-->
  <view class="home-view2">
    <image class="home-image1" src="http://qty83k.creatby.com/materials/origin/640e31829b8776967dedc670b5427d0f_origin.jpg"></image>
  </view>
  
  <!--描述层-->
  <text class="home-text1">小巧可爱的案头雅物小巧可爱的案头雅物小巧可爱的案头雅物小巧可爱的案头雅物小巧可爱的案头雅物</text>
  
  <!--信息层-->
  <view class="home-view3">
    <view class="home-view4" >
      <image class="home-image-heart" src="http://qty83k.creatby.com/materials/origin/c5656ef00d38d89eae437c5a9102f8fa_origin.png"></image>
  
      <text class="home-text-heart bgColor" > 22</text>
    </view>
    <text class="home-text-time" >2016.10.29</text>
  </view>
  
  <!--分界线line-->
  <view class="home-view-line"></view>
  
  <!--图片层(下面的代码直接复制了上面的所有布局代码)-->
  <view class="home-view2">
    <image class="home-image1" src="http://qty83k.creatby.com/materials/origin/640e31829b8776967dedc670b5427d0f_origin.jpg"></image>
  </view>
  
  <!--描述层-->
  <text class="home-text1">小巧可爱的案头雅物小巧可爱的案头雅物小巧可爱的案头雅物小巧可爱的案头雅物小巧可爱的案头雅物</text>
  
  <!--信息层-->
  <view class="home-view3">
    <view class="home-view4" >
      <image class="home-image-heart" src="http://qty83k.creatby.com/materials/origin/c5656ef00d38d89eae437c5a9102f8fa_origin.png"></image>
  
      <text class="home-text-heart bgColor" > 22</text>
    </view>
    <text class="home-text-time" >2016.10.29</text>
  </view>
  
  <!--分界线line-->
  <view class="home-view-line"></view>
  
</view>

이 포함됩니다. 구현

은 페이지 인터페이스

Page({
  
  data:{
  
  }
  
})

를 등록합니다. 3. 스타일 구현

.home-view1 스타일: display는 최대 뷰 레이아웃을 지정합니다. 유연한 레이아웃, 단지ify-content가 콘텐츠가 중앙에 있고 수직으로 정렬되도록 지정하는 경우 ...

.home-view3 스타일: 디스플레이는 정보 표시줄 레이아웃이 유연한 레이아웃임을 지정합니다. , justify-content는 콘텐츠가 수평으로 고르게 분포되도록 지정합니다.

.home-view4 스타일: display는 컬렉션 사진과 컬렉션 번호의 상위 레이아웃이 유연한 레이아웃임을 지정하고 align-items는 콘텐츠가 중앙에 정렬되도록 지정합니다. 수직

.home- image1 스타일: 이미지의 높이를 지정

.home-image-heart 스타일: 수집된 이미지의 크기를 지정

.home-text1 style: 설명 텍스트의 스타일을 지정합니다. text-align 텍스트를 가운데로 지정합니다. line-height텍스트 두 줄 사이의 높이를 지정합니다

. home-text-heart 스타일: 컬렉션 번호의 스타일을 지정합니다. border-radius는 테두리 필렛을 지정합니다

.home-view-line 스타일: 구분선

.bgColor 스타일: 컬렉션 번호의 배경 지정

.home-view1{
  display: flex;
  justify-content: center;
  flex-direction: column;
  
  height: 100%;
  width: 100%;
  margin: 6px;
  
}
  
.home-view3{
  display: flex;
  justify-content: space-between;
}
  
.home-view4{
  display: flex;
  align-items: center;
}
  
.home-image1{
  height: 200px;
}
  
.home-image-heart{
  width: 30px;
  height: 30px;
}
  
.home-text1{
  text-align: left;
  line-height: 25px;
  margin-top: 6px;
  margin-right: 6px;
  color: gray;
}
  
.home-text-heart{
  width: 22px;
  height: 22px;
  margin-left: 10px;
  border-radius: 20%;
  pad: 5px;
  text-align: center;
}
  
.home-text-time{
  text-align: center;
  margin-right: 20px;
  padding-top: 5px;
  color: gray;
}
  
.home-view-line{
  
 width: 100%;
 height: 6px;
 margin-top: 5px;
 background-color: gainsboro;
}
  
.bgColor{
  background-color: lightblue;
  opacity: 0.6;
}

【 관련 추천】

1. WeChat 미니 프로그램 전체 소스 코드 다운로드

2. WeChat 미니 프로그램 학습 데모: 채팅방 + 오디오 및 비디오 + 콘텐츠 추가

위 내용은 미니 프로그램 개발 DEMO 사례의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.