使用trao trao-ui 的歷程

修改trao-ui組件中的默認樣式

搜索組件中我不想要搜索按鈕

<AtSearchBar value={this.state.value}
             onChange={this.handleChange}
             className="searchNoBtn"

然後再全局樣式中添加:我的就在app.less文件

.searchNoBtn {
  .at-search-bar__action {
    display: none !important;
  }
}

不能用函數組件 會提示react undefined

 const renderLabel = (list) => {
   return list.map(v => {
     return (
       <AtTag>{v}</AtTag>
     )
   })
 };

這麼寫會報錯。
可以直接在class 裏面對數組進行map

<View className="panel-main">
{
 historyList.map((item, i) => {
    return <AtTag key={i}
      {item}
    </AtTag>
  })
}
</View>

使用圖片

直接將相對路徑放在src屬性中,不起作用,
需要先import進來,最好把圖片放到服務器上,然後直接寫http路徑

錯誤寫法:

<Image src="./images/front.png" />

正確寫法:

import namedPng from './images/front.png'
...
<Image src={namedPng} />

當進入頁面就請求數據

componentDidShow 對應微信小程序的 onShow 方法。

taro裏面沒有this.props.history屬性。

參考文章

部分頁面加載動畫

this.state.loading ? <AtActivityIndicator mode='center' content='加載中...'/> : null

官網

切換tab

使用navigateToredirectTo會報錯navigateTo:fail can not navigateTo a tabbar page

Taro.switchTab({
	url: '/pages/index/index',
})
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章