Intro.自定義tabBar的配置
在app.json檔案的UsingComponents下注冊
"tabBar": {
"borderStyle": "white",
"selectedColor": "#333333",
"color": "999999",
"list": [
{
"text": "閱讀",
"pagePath": "pages/post/post",
"iconPath": "/images/tab/post.png"/>
注意跳轉到有選項卡的頁面需要使用switchTab
如何創建第一個自定義組件
①根目錄下創建components>post>index
②components>post>index.js中定義屬性
properties: {
text: {
type: String,//型別
value: ‘123’//默認值
}
}
③在page > xx.json 定義名稱
“usingComponents”: {
“c-post”:"/components/post/index"
}
④在page > xx.wxml中使用
⑤components > post > index.wxml
{{text}}
自定義組件屬性
自定義的屬性 text 也可以做資料系結
快速自定義屬性時,無法自定義默認值
properties: {
text: String // 也可以為Number(默認值為0)、Object、Boolean(默認值為false)
}
把原來post頁面的文章部分作為一個組件,wxml和wxss復制到組件對應下wxml和wxss下
為什么index.wxml(組件的)列印data和posts.wxml不一樣:
posts里面data是自帶的,所以不用,直接去列印res,然而index是接受到res放進properties
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/273800.html
標籤:其他
上一篇:字少事大|兩張表格教你快速選擇適合的MCU進行物聯網開發
下一篇:安裝Gin核心步驟(win7)
