Home  >  Article  >  WeChat Applet  >  WeChat Mini Program Development-Creating a Welcome Page

WeChat Mini Program Development-Creating a Welcome Page

高洛峰
高洛峰Original
2018-05-25 10:00:086054browse

In the previous article, we introduced the basic directory structure of the WeChat applet and the role of each file.
In this article, I will create the first page with you, the welcome page.

Let’s take a look at the final rendering: 微信小程序开发-创建欢迎页面
First open the WeChat WEB developer tool, create a quick start project, and make simple modifications. The directory structure is as follows:
微信小程序开发-创建欢迎页面

  • Rename the Index folder to welcome;

  • Change the hello world at the bottom to A style similar to a button;

  • Add a background color; Modify the top style;

Button implementation:
The following is the WXML code of the welcome page:

<!--index.wxml-->
<view class="container">
  <view  bindtap="bindViewTap" class="userinfo">
    <image class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image>
    <text class="userinfo-nickname">{{userInfo.nickName}}</text>
  </view>
  <view class="usermotto">
    <text class="btn">欢迎进入小程序开发</text>
  </view>
</view>

The following is the WXSS code of the welcome page:

/**index.wxss**/
.userinfo {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.userinfo-avatar {
  width: 128rpx;
  height: 128rpx;
  margin: 20rpx;
  border-radius: 50%;
}

.userinfo-nickname {
  color: #aaa;
}

.userinfo image{
  width: 200rpx;
  height: 200rpx;
  border-radius: 50%;
}

.usermotto {
  margin-top: 200px;
  border: 1px solid #405f80;
  width: 250rpx;
  height: 80rpx;
  text-align: center;
  border-radius: 5px;
}
.btn{
  font-size: 22rpx;
  font-family: MicroSoft Yahei;
  font-weight: bold;
  line-height: 80rpx;
}
page{
  height: 100%;
  background: #ECF8EB;
}

Setting of background color:

Note: Setting the width and height to 100% in the outermost view and adding a background color are invalid. Because WeChat has a page outside by default.

微信小程序开发-创建欢迎页面
So you need to write like this:

page{
  height: 100%;
  background: #ECF8EB;
}

Top settings:
app.jason code is as follows:

{
  "pages":[
    "pages/welcome/welcome"
    
  ],
  "window":{
    "backgroundTextStyle":"light",
    "navigationBarBackgroundColor": "#ECF8EB",
    "navigationBarTitleText": "欢迎",
    "navigationBarTextStyle":"black"
  }
}

For more WeChat applet development-creating a welcome page, please pay attention to the PHP Chinese website for related articles!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn