上一篇中,我們介紹了微信小程序的基本目錄結(jié)構(gòu),各個文件的作用。愛掏網(wǎng) - it200.com
本篇跟大家一起創(chuàng)建第一個頁面,歡迎頁面。愛掏網(wǎng) - it200.com
先看下最后的效果圖:
首先打開微信WEB開發(fā)者工具,創(chuàng)建quick start項目,簡單的修改一下。愛掏網(wǎng) - it200.com 目錄結(jié)構(gòu)如下圖:
把Index文件夾重命名為welcome;
底部的hello world改為一個類似于按鈕的樣式;
添加背景顏色; 修改頂部樣式;
按鈕的實現(xiàn):
下面是welcome頁面的WXML代碼:
登錄后復(fù)制{{userInfo.nickName}} 歡迎進入小程序開發(fā)
下面是welcome頁面的WXSS代碼:
/**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; }登錄后復(fù)制
背景顏色的設(shè)置:
注意:在最外部的view設(shè)置寬高百分百,添加背景顏色是無效的。愛掏網(wǎng) - it200.com因為微信默認(rèn)外面還有一層page。愛掏網(wǎng) - it200.com
所以需要這樣寫:
page{ height: 100%; background: #ECF8EB; }登錄后復(fù)制
頂部設(shè)置:
app.jason代碼如下:
{ "pages":[ "pages/welcome/welcome" ], "window":{ "backgroundTextStyle":"light", "navigationBarBackgroundColor": "#ECF8EB", "navigationBarTitleText": "歡迎", "navigationBarTextStyle":"black" } }登錄后復(fù)制
更多微信小程序開發(fā)-創(chuàng)建歡迎頁面?相關(guān)文章請關(guān)注愛掏網(wǎng) - it200.com!
聲明:所有內(nèi)容來自互聯(lián)網(wǎng)搜索結(jié)果,不保證100%準(zhǔn)確性,僅供參考。如若本站內(nèi)容侵犯了原著者的合法權(quán)益,可聯(lián)系我們進行處理。