修改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
使用navigateTo
和redirectTo
會報錯navigateTo:fail can not navigateTo a tabbar page
Taro.switchTab({
url: '/pages/index/index',
})