


Summary of problems encountered in mini program development
Apr 06, 2021 am 11:24 AMMini program interview questions
1.What is the difference between bindtap and catchtap?
bindEvent binding will not prevent bubbling events from bubbling up. catchEvent binding It can definitely prevent bubbling events from bubbling upward
2, Js arrays are converted to strings, forced to be converted to integers and converted to floating point numbers. What are the functions?
js provides two conversion functions: parseInt() and parseFloat(). The former converts the value to an integer, and the latter converts the value to a floating point number. Only by calling these methods on the String type can these two functions run correctly; for other types, NaN (Not a Number) is returned.
Related free learning recommendations: WeChat Mini Program Development
1. Conversion function:
#Both parseInt() and parseFloat() will carefully analyze the string before determining whether it is a numeric value. The parseInt() method first checks the character at position 0 to determine whether it is a valid number; if not, the method will return NaN and will not continue to perform other operations. But if the character is a valid number, the method will look at the character at position 1 and perform the same test. This process will continue until a character that is not a valid number is found, at which time parseInt() will convert the string before the character into a number.
parseInt("1234blue"); //returns 1234 parseInt("0xA"); //returns 10 parseInt("22.5"); //returns 22 parseInt("blue"); //returns NaN
#2. Forced type conversion
You can also use type casting to process the conversion value type. Use a cast to access a specific value, even if it is of another type.
The three types of forced type conversions available in ECMAScript are as follows:
Boolean(value) - Convert the given value to Boolean type;
Number(value)——Convert the given value into a number (can be an integer or floating point number);
String(value)——Convert the given value into a character string.
3. Use weak type conversion of js variables
Take a small example and you will understand it at a glance .
<script> var str= '012.345 '; var x = str-0; x = x*1; </script>
The above example takes advantage of the weak type characteristics of js and only performs arithmetic operations to achieve string to Number type conversion, but this method is not recommended.
3, Briefly describe the related file types of the WeChat applet.
Mini program: pages ——index: index.js(Page logic) /index.wxml (Page structure)/index.wxss (Page Style sheet) / index.json (Page configuration)
App.js Mini program logic
App.json Mini program public settings
App.wxss Mini program public style sheet
4、The mini program has What are the methods for passing parameter values?
1. Set the id method to identify the parameter value passed after the jump;
2. Use the data - xxxx method to identify the value to be passed
The WeChat applet sets the id method identifier to pass the value
At the item to be jumped, set an id and assign the corresponding value to the current id The key value, such as the id of a movie (then go to the next page with the id to query for detailed information), such as:
After that, we obtain it in the response event of bindtap in js and pass it to the next page. In an interface;
Get the value passed by id
Get the set id value through e.currentTarget.id; and set the global object's Method to pass values,
Get the global object var app=getApp(); //Set the parameters passed by the global request access app.requestDetailid=id;
Tip: In fact, we can also view the id value of each item we set in wxml
通過使用data - xxxx 的方法標識來傳值
通過使用data - xxxx 的方法標識來傳值,xxxx可以自定義取名 比如data-key等等都可以。
如何獲取data-xxxx傳遞的值?
在js的bindtap的響應(yīng)事件中:
通過數(shù)據(jù)解析一層層找到數(shù)據(jù),var id=e.target.dataset.id(根據(jù)你的data-id的取名)
微信小程序如何跨頁面獲取值?
依據(jù)上面的方式設(shè)置要傳遞的值,頁面跳轉(zhuǎn)后,我們就需要在下一個頁面拿到傳遞的數(shù)據(jù)(這個數(shù)據(jù)在傳遞前,就已經(jīng)被設(shè)置成全局變量)
在跳轉(zhuǎn)后的js頁面,接收傳遞過來的數(shù)據(jù)detail.js
同樣通過全局額方式取值出來,(即和app.js中取某個變量的值是一樣的)
var movieid=getApp().MovieDetailid;
console.log(movieid);
5、簡述下wx.navigateTo(), wx.redirectTo(), wx.switchTab(), wx.navigateBack(), wx.reLaunch()的區(qū)別?
微信小程序 跳轉(zhuǎn)頁面
小程序頁面有2種跳轉(zhuǎn),可以在wxml頁面或者js中:
1,在wxml頁面中:
<navigator url="../index/index">跳轉(zhuǎn)到新頁面</navigator> <navigator url="../index/index" open-type="redirect">在當前頁打開</navigator> <navigator url="../index/index" open-type="switchTab">切換到首頁Tab</navigator>
2,在js頁面中:
【注意】此處注意兩個關(guān)鍵詞 “應(yīng)用內(nèi)的頁面” 和 “tabBar頁面”。 app.json文件中tabBar中注冊過的tab頁,即為“tabBar頁面”,非tabBar中注冊占用的頁面即為“應(yīng)用內(nèi)的頁面” 。 如下圖:home頁面為“應(yīng)用內(nèi)的頁面”,index和logs頁面則為 “tabBar頁面”。
3,如果上述跳轉(zhuǎn)遇到跳轉(zhuǎn)失敗或無效的問題,請訪問下面鏈接:
wx.navigateTo/wx.redirectTo 無效
6、如果需要用戶授權(quán),用戶選擇拒絕授權(quán),此時應(yīng)該如何處理?
在微信小程序開發(fā)時,當我們調(diào)用API wx.getUserInfo(OBJECT) 時,需要用戶授權(quán)。但如果用戶拒絕授權(quán),我們?nèi)绾渭嫒萦脩艟芙^授權(quán)狀態(tài),擁有更好的用戶體驗?zāi)兀?/p>
先看看這個接口的官方文檔:
wx.getUserInfo(OBJECT)
獲取用戶信息,需要先調(diào)用 wx.login 接口。
OBJECT參數(shù)說明:
參數(shù)名 | 類型 | 必填 | 說明 |
withCredentials | Boolean | 否 | 是否帶上登錄態(tài)信息 |
success | Function | 否 | 接口調(diào)用成功的回調(diào)函數(shù) |
fail | Function | 否 | 接口調(diào)用失敗的回調(diào)函數(shù) |
complete | Function | 否 | 接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行) |
1. tip: wx.getUserInfo 接口需要用戶授權(quán),請兼容用戶拒絕授權(quán)的場景。
我們就是要在用戶點擊拒絕的時候,彈出提示框,提示用戶以提升用戶體驗。像下面這樣的。
用具體代碼實現(xiàn)就是,將彈窗寫在 wx.getUserInfo 的fail回調(diào)函數(shù)中,像下面這樣:
wx.getUserInfo({ success: function (resuser) { console.log(success) }, fail: function () {// 調(diào)用微信彈窗接口 wx.showModal({ title: '警告', content: '您點擊了拒絕授權(quán),將無法正常使用******的功能體驗。請10分鐘后再次點擊授權(quán),或者刪除小程序重新進入。', success: function (res) { if (res.confirm) { console.log('用戶點擊確定') } } }) } })
這樣用戶就獲得了提示信息,但此時,用戶還是停留在頁面的,如果某些展示信息,還是給要給用戶展示的,只是在進行某些操作的時候要對授權(quán)進行驗證的話,那就得繼續(xù)修改我們的代碼,保存用戶的登錄態(tài),在其他地方做驗證使用。
第一種思路:
保存登錄態(tài)這里是這樣的,將用戶的登錄信息傳給后臺,后臺保存用戶信息,同時用 open_id 在后臺換取一個SessionId 用換取的這個SessionId 存在緩存,做為登錄態(tài)驗證。
wx.getUserInfo({ success: function (resuser) { let userInfo = resuser.userInfo that.healthApi.login(code, userInfo).then(logindata => { // 這里將微信的請求封裝成Promiese 風格 if (logindata.code === 0) { var sessionId = logindata.data// 調(diào)用微信wechat.setStorage將換回來的 SessionId 存在本地緩存 that.wechat.setStorage('sessionId', sessionId).then(() => { that.globalData.userInfo = userInfo typeof cb == "function" && cb(that.globalData.userInfo) }) } }) }, fail: function () { wx.showModal({ title: '警告', content: '您點擊了拒絕授權(quán),將無法正常使用*****的功能體驗。請10分鐘后再次點擊授權(quán),或者刪除小程序重新進入。', success: function (res) { if (res.confirm) { console.log('用戶點擊確定') } } }) } })
這樣我們將登錄態(tài)保存在了 SessionId 中,在每次登錄的時候我們只需要再調(diào)用一個 檢查 SessionId的接口就行,檢查不通過再調(diào)微信登錄接口。此處不做延伸了。
第二種思路:
在3.29微信小程序更新的版本中,加入了這樣一條屬性
withCredentials 字段基礎(chǔ)庫版本 1.1.0 開始支持,低版本需做兼容處理
這個字段的意思就是調(diào)用 wx.getUserInfo(OBJECT) 是否帶上 登錄態(tài) 的信息。
官方文檔是這樣解釋的:
withCredentials 字段基礎(chǔ)庫版本 1.1.0 開始支持,低版本需做兼容處理
注:當 withCredentials 為 true 時,要求此前有調(diào)用過 wx.login 且登錄態(tài)尚未過期,此時返回的數(shù)據(jù)會包含 encryptedData, iv 等敏感信息;當 withCredentials 為 false 時,不要求有登錄態(tài),返回的數(shù)據(jù)不包含 encryptedData, iv 等敏感信息。
success返回參數(shù)說明:
參數(shù) | 類型 | 說明 |
userInfo | OBJECT | 用戶信息對象,不包含 openid 等敏感信息 |
rawData | String | 不包括敏感信息的原始數(shù)據(jù)字符串,用于計算簽名。 |
signature | String | 使用 sha1( rawData + sessionkey ) 得到字符串,用于校驗用戶信息。 |
encryptedData | String | 包括敏感數(shù)據(jù)在內(nèi)的完整用戶信息的加密數(shù)據(jù),詳細見加密數(shù)據(jù)解密算法 |
iv | String | 加密算法的初始向量,詳細見加密數(shù)據(jù)解密算法 |
注:需要兼容微信低版本,向后兼容。
那么利用這個接口,我們可以直接拿到 登錄狀態(tài),在其他需要驗證登錄的地方進行提示,而在不需要授權(quán)的地方還可以讓用戶瀏覽小程序。
回到前面的問題,在用戶點擊拒絕授權(quán)后,在某些操作時需要驗證用戶是否授權(quán)過,彈出交互信息,那么就利用上面的 SessionId或者 withCredentials 登錄態(tài)進行下面的操作:
applyIn: function applyIn() { if (wx.getStorageSync('sessionId')) { // 根據(jù)儲存的sessionId 進行驗證 wx.navigateTo({ url: 'familyDoctorApply/familyDoctorApply?Oid=' + this.data.params.Oid + '&title=' + this.data.params.title + '&serviceCity=' + this.data.array[this.data.index].name + '&productPrice=' + this.data.product.productPrice }); } else { wx.showModal({ title: '警告', content: '您點擊了拒絕授權(quán),無法使用此功能。', success: function (res) { if (res.confirm) { console.log('用戶點擊確定') } } }) }
效果像這樣:
這樣一個簡單完整的登錄及授權(quán),登錄態(tài)保存等前端微信小程序解決方案就完成了,還可以繼續(xù)擴展到登錄有效期,退出登錄,用戶權(quán)限等跟多擴展的地方。
7、你平時封裝可以復(fù)用的方法嗎?你會把可以復(fù)用的方法寫在哪個文件里?
其實可以模擬一些框架的,比如bootsrap,寫個demo出來,抽出css和js,js最好抽象成對象(構(gòu)造函數(shù))或者是帶參數(shù)的方法,然后你只要聲明對像,或者參數(shù)指定某個class或id,就可以了
寫在html文件里有什么優(yōu)點嗎?
獨立出來會有什么問題嗎?尤其是載入頁面的時候,應(yīng)該會多發(fā)很多http請求吧,會不會造成加載變慢?
8、分析下小程序的優(yōu)劣勢?
小程序是在微信生態(tài)發(fā)展過程中新出現(xiàn)的一種應(yīng)用形態(tài),小程序的小,從某種程度上已經(jīng)說明了它的體量不會很大,但是可以實現(xiàn)一些功能相對簡單、交互相對簡單的服務(wù)需求,同時解決了App長期以來多平臺適配、多應(yīng)用市場分發(fā)、開發(fā)成本居高不下等諸多方面的問題。所以小程序【密件】依靠微信平臺和自身“閱后即焚”的功能,獲得眾多年輕人的好評
優(yōu)勢:
1)容易上手,只要之前有HTML+CSS+JS基礎(chǔ)知識,寫小程序基本上沒有大問題;當然如果了解ES6+CSS3則完全可以編寫出即精簡又動感的小程序;
2)基本上不需要考慮兼容性問題,只要微信可以正常運行的機器,就可以運行小程序;
3)基本組件庫已經(jīng)比較齊全:Toast,Loading框,Picker,定位及地圖,Image,Input,Checkbox,Text,TextArea,ScrollView等常用的組件都有,而且使用也挺簡單、方便;
4)發(fā)布、審核高效,基本上上午發(fā)布審核,下午就審核通過,升級簡單,而且支持灰度發(fā)布;
5 ) 微信官方提供使用人數(shù)、頻率等數(shù)據(jù)統(tǒng)計,小程序js腳本執(zhí)行錯誤日志;
6)開發(fā)文檔比較完善,開發(fā)社區(qū)比較活躍;
7)最近剛開放的牛x功能,新增webview組件,可以展示網(wǎng)頁啦,這個比較爽;
8)支持插件式開發(fā),一些基本功能可以開發(fā)成插件,供多個小程序調(diào)用;
劣勢:
1)后臺調(diào)試麻煩,因為API接口必須https請求,且公網(wǎng)地址,也就是說后臺代碼必須發(fā)布到遠程服務(wù)器上;當然我們可以修改host進行dns映射把遠程服務(wù)器轉(zhuǎn)到本地,或者開啟tomcat遠程調(diào)試;不管怎么說終歸調(diào)試比較麻煩。
2)前臺測試有諸多坑,最頭疼莫過于模擬器與真機顯示不一致(之前碰到一個案例,后續(xù)單獨講解)
3)真機測試,個別功能安卓和蘋果表現(xiàn)迥異,我們的小程序里有很多頁面有定位功能,模擬器和iphone定位瞬間完成,然而安卓手機就蛋疼了,老顯示“定位中...”要很久才能定位好。后來沒辦法只能優(yōu)化,減少定位次數(shù)。
4)native組件,展示很不好,比如textarea,不能在滾動頁面出現(xiàn),而且至于頂層,經(jīng)常其它組件會被它遮擋,點擊其它組件時,就進入textarea輸入框;畫布組件也是如此;
5)頁面跳轉(zhuǎn)深度不能超過5個頁面,這個比較麻煩,有些復(fù)雜的頁面跳轉(zhuǎn)沒法實現(xiàn),不過太復(fù)雜的話也有悖小程序簡單易用的原則啦;
6)小程序升級問題,官方文檔說會自動更新,實際情況往往是要先把原來的小程序刪除掉,重新搜索添加,才能加載最新版本;
7)頁面渲染穩(wěn)定性有待提高,已經(jīng)好幾次出現(xiàn)部分用戶的頁面顯示異常,整個頁面被放大了好幾倍,先刪除原來小程序再添加回來,如此重復(fù)好幾次,才能顯示正常;
8)js引用只能使用絕對路徑,很蛋疼;基于安全性及MINA框架實現(xiàn)原理,小程序中對js使用做了很多限制,不能使用:new Function,eval,Generator,不能操作cookie,不能操作DOM;
9)開發(fā)工具bug比較多且效率比較低,三天兩頭升級,解決老問題的同時又出現(xiàn)問題;文件查找、資源定位、代碼編輯較eclipse有一定差距。經(jīng)常出現(xiàn)把a.js當做b.js來修改
9、設(shè)置值到頁面暫存區(qū)(即data)里面的方法有幾種?分別是什么?有什么區(qū)別?
1. 使用QueryString變量
QueryString是一種非常簡單的傳值方式,他可以將傳送的值顯示在瀏覽器的地址欄中。如果是傳遞一個或多個安全性要求不高或是結(jié)構(gòu)簡單的數(shù)值時,可以使用這個方法。但是對于傳遞數(shù)組或?qū)ο蟮脑挘筒荒苡眠@個方法了。下面是一個例子:
a.aspx的C#代碼
private void Button1_Click(object sender, System.EventArgs e) { string s_url; s_url = "b.aspx?name=" + Label1.Text; Response.Redirect(s_url); } b.aspx中C#代碼 private void Page_Load(object sender, EventArgs e) { Label2.Text = Request.QueryString["name"]; }
2. 使用Application 對象變量
Application對象的作用范圍是整個全局,也就是說對所有用戶都有效。其常用的方法用Lock和UnLock。
a.aspx的C#代碼
private void Button1_Click(object sender, System.EventArgs e) { Application["name"] = Label1.Text; Server.Transfer("b.aspx"); } b.aspx中C#代碼 private void Page_Load(object sender, EventArgs e) { string name; Application.Lock(); name = Application["name"].ToString(); Application.UnLock(); }
3. 使用Session變量
想必這個肯定是大家使用中最常見的用法了,其操作與Application類似,作用于用戶個人,所以,過量的存儲會導(dǎo)致服務(wù)器內(nèi)存資源的耗盡。
a.aspx的C#代碼
private void Button1_Click(object sender, System.EventArgs e) { Session["name"] = Label.Text; } b.aspx中C#代碼 private void Page_Load(object sender, EventArgs e) { string name; name = Session["name"].ToString(); }
4. 使用Cookie對象變量
這個也是大家常使用的方法,與Session一樣,其是什對每一個用戶而言的,但是有個本質(zhì)的區(qū)別,即Cookie是存放在客戶端的,而session是存放在服務(wù)器端的。而且Cookie的使用要配合ASP.NET內(nèi)置對象Request來使用。
a.aspx的C#代碼
private void Button1_Click(object sender, System.EventArgs e) { HttpCookie cookie_name = new HttpCookie("name"); cookie_name.Value = Label1.Text; Reponse.AppendCookie(cookie_name); Server.Transfer("b.aspx"); } b.aspx中C#代碼 private void Page_Load(object sender, EventArgs e) { string name; name = Request.Cookie["name"].Value.ToString(); }
5. 使用Server.Transfer方法
這個才可以說是面象對象開發(fā)所使用的方法,其使用Server.Transfer方法把流程從當前頁面引導(dǎo)到另一個頁面中,新的頁面使用前一個頁面的應(yīng)答流,所以這個方法是完全面象對象的,簡潔有效。
a.aspx的C#代碼
public string Name { get{ return Label1.Text;} } private void Button1_Click(object sender, System.EventArgs e) { Server.Transfer("b.aspx"); } b.aspx中C#代碼 private void Page_Load(object sender, EventArgs e) { a newWeb; //實例a窗體 newWeb = (source)Context.Handler; string name; name = newWeb.Name; }
微信小程序--data的賦值與取值
通過小程序官方文檔可知:
Page() 函數(shù)用來注冊一個頁面。接受一個 object 參數(shù),其指定頁面的初始數(shù)據(jù)、生命周期函數(shù)、事件處理函數(shù)等。其中的參數(shù)data用來設(shè)置初始數(shù)據(jù),WXML 中的動態(tài)數(shù)據(jù)均來自對應(yīng) Page 的 data。
所以如果頁面需要顯示動態(tài)數(shù)據(jù)必須要把數(shù)據(jù)更新到data中對應(yīng)的變量中。
頁面js文件中這么寫:
Page({ data: { message: 'Hello MINA!' } }) · wxml中這么寫: <view> {{ message }} </view>
如果該數(shù)據(jù)在操作過程中發(fā)生變化,需要將新數(shù)據(jù)重新綁定到該變量中,寫法如下:
function setData(){ var that = this; that.setData({ message: '新消息' }) }
如果想在js文件中使用data中的數(shù)據(jù)寫法如下:
function getData(){ var that = this; console.log(that.data.message) }
10、如何檢測用戶的微信版本是否支持某項功能?
The interfaces opened in the first phase are not unusable, but do not need to be tested, and all are supported.
Only the latest open interfaces need to be tested for support.
All currently open interfaces:
onMenuShareTimeline
onMenuShareAppMessage
onMenuShareQQ
onMenuShareWeibo
onMenuShareQZone
startRecord
stopRecord
onVoiceRecordEnd
playVoice
pauseVoice
stopVoice
onVoicePlayEnd
uploadVoice
downloadVoice
chooseImage
previewImage
uploadImage
downloadImage
translateVoice
getNetworkType
openLocation
getLocation
hideOptionMenu
showOptionMenu
hideMenuItems
showMenuItems
hideAllNonBaseMenuItem
showAllNonBaseMenuItem
closeWindow
scanQRCode
chooseWXPay
openProductSpecificView
addCard
chooseCard
openCard
# #11. How to sub-package loading? What are the advantages of subpackage loading?
Introduction to subpackage loading
Most small programs will be composed of certain functions, usually these few The functions are independent of each other, but rely on some common logic, and these functions usually correspond to several independent pages. Then the package of the mini program code does not have to be bundled into one package. It can be split into several sub-packages according to the division of functions. When a certain function is needed, the sub-package corresponding to this function is loaded.
For users, the mini program loading process becomes:
1. When starting for the first time, first download the main package of the mini program and display the pages in the main package ;
2. If the user enters a certain subpackage page, and then downloads the corresponding subpackage, after the download is completed, the subpackage page is displayed.
Using sub-packaging loading, for developers, the mini program can have a larger code volume and carry more functions and services; for users, it can be opened faster Mini program, while using more functions without affecting startup speed.
Division of subcontracts
Before configuring, developers first need to plan the content that each subcontract needs to accommodate. We recommend that developers follow The principle of function division is to place pages and logic under the same function in the same directory. For some common logic between cross-functions, place it under the main package. This ensures that when subcontracting references to this part of the function , this part of the logic must exist.
When subcontracting, you should pay attention to the following matters:
1. Avoid coupling of references between subcontracts. Because the loading of sub-packages is triggered by user operations, there is no guarantee that when a certain sub-package is loaded, another sub-package will definitely exist. This may cause JS logic exceptions, such as reporting ""xxx.js" is not defined";
2. Some publicly used custom components need to be placed in the main package.
Subcontracting configuration
After clarifying the subcontracting division, you can configure the subcontracting. This step does not include Not complicated.
假設(shè)支持分包的小程序目錄結(jié)構(gòu)如下:
開發(fā)者通過在 app.json subPackages 字段聲明項目分包結(jié)構(gòu):
分包加載的低版本兼容問題
微信 6.6.0 版本開始支持分包加載,而對于低于這個版本的客戶端,我們做了兼容處理,開發(fā)者不需要對老版本微信客戶端做兼容。對于老版本的客戶端,編譯后臺會將所有的分包打包成一個整包,老版本的客戶端依然按照整包的方式進行加載。
所以在老版本的微信客戶端下,是依然采取整包加載的方式加載的,建議開發(fā)者盡量控制代碼包的大小。
目前小程序分包大小的限制:
整個小程序所有分包大小不超過 4M
單個分包/主包大小不能超過 2M
隨著時間推移,老版本覆蓋率降低,我們會考慮進一步擴大代碼包的大小。
12、在你開發(fā)小程序的過程中遇到過什么坑? 你是怎么解決的?
1.我們使用app.json文件來對微信小程序進行全局配置,決定頁面文件的路徑、窗口表現(xiàn)、設(shè)置網(wǎng)絡(luò)超時時間、設(shè)置多 tab 的時候在pages中寫注釋的時候回報錯。
例如:
{ "pages":[ //這是首頁面 "pages/welcome/welcome" ]}
此時就會報錯
2.在json文件中沒有寫內(nèi)容的時候也要加一對大括號{ },不然的話也會報錯
3. ①在開發(fā)微信小程序的時候,我們使用app.json文件來對微信小程序進行全局配置,決定頁面文件的路徑,窗口表現(xiàn),設(shè)置網(wǎng)絡(luò)超時時間,設(shè)置多Tab等。
以下是一個包含了所有配置選項的簡單配置,app.json :
{ //設(shè)置頁面路徑 "pages": [ "pages/index/index", "pages/logs/index" ], //設(shè)置默認頁面的窗口表現(xiàn) "window": { "navigationBarTitleText": "Demo" }, //設(shè)置底部 tab 的表現(xiàn) "tabBar": { "list": [{ "pagePath": "pages/index/index", "text": "首頁" }, { "pagePath": "pages/logs/logs", "text": "日志" }] }, //設(shè)置網(wǎng)絡(luò)超時時間 "networkTimeout": { "request": 10000, "downloadFile": 10000 }, //設(shè)置是否開啟 debug 模式 "debug": true }
②但是在對頁面json文件進行配置的時候只可以配置設(shè)置默認頁面的窗口表現(xiàn)(即只能對window進行配置),但是在此時可以直接省略window,如果加window則沒有效果,也不會報錯。
以下是一個包含了window配置選項的簡單配置,post.json :
注意:這是錯誤的寫法
{ "window":{ "navigationBarBackgroundColor": "#ffffff", "navigationBarTextStyle": "black", "navigationBarTitleText": "微信接口功能演示", "backgroundColor": "#eeeeee", "backgroundTextStyle": "light" }}
注意:正確的寫法
{ "navigationBarBackgroundColor": "#ffffff", "navigationBarTextStyle": "black", "navigationBarTitleText": "微信接口功能演示", "backgroundColor": "#eeeeee", "backgroundTextStyle": "light"}
4.此前一直沒有注意vertical-align: middle和height:40rpx;line-height:40rpx進行設(shè)置垂直劇中的區(qū)別,這次主要說一下vertical-align: middle
代碼如下:
<view class="post-author-date"> <image class="post-author" src="../../images/avatar/1.png"> </image> <text class="post-date">Nov 15 2016</text> </view> .post-author{ width: 60rpx; height: 60rpx; vertical-align: middle; } .post-date{ margin-top: 5rpx; vertical-align: middle; /*height: 40rpx; line-height: 40rpx;*/ }
總結(jié):?
①vertical-align: middle;把此元素放在父元素的中部?
②當一個父元素里面有多個子元素,需要把幾個子元素水平對齊,并且每個子元素都垂直劇中的時候,對每一個子元素進行設(shè)置 vertical-align: middle?
③height: 40rpx; line-height: 40rpx;可以對文本進行垂直居中
相關(guān)學(xué)習(xí)推薦:小程序開發(fā)教程
The above is the detailed content of Summary of problems encountered in mini program development. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)