一、Taro-UI使用
-
不要使用官網(wǎng)Taro-UI中快速上手安裝Taro-UI翰铡,安裝之后編譯會報錯。
- 如果不小心安裝了伐割,請先清空nodemodules文件夾中taro-ui文件夾莫辨,重新安裝3.0版本的Taro-UI
npm install taro-ui@3.0.0.0-alpha.3
二、TSX寫組件注意事項
- 需要import component from react结啼,組件類要extends該component
import React, { Component } from 'react'
import { AtInput, AtForm } from 'taro-ui'
export default class CollectionData extends Component {
}
- 不可以通過import taro from @tarojs/taro掠剑,會提示
“TypeError:Super expression must either be null or a function”
import React from 'react'
import Taro from '@tarojs/taro'
import { AtInput, AtForm } from 'taro-ui'
export default class CollectionData extends Taro.Component {
}
- 申明了一個數(shù)組,但是沒有指定元素類型郊愧,則需要在Component中指定類型為<any any>朴译,否則會顯示錯誤
“類型“Readonly<{}>”上不存在屬性‘xxxxxx’”
三、view樣式設置寬高百分比無效的問題
- 在最頂層設置一個標簽page的樣式属铁,指定寬高100%即可
page{
height: 100%;
width: 100%;
.index {
height: 100%;
width: 100%;
background: no-repeat;
background-image: url("../../images/home-page/homepage.jpg");
background-size: 100% 100%;
}
}
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者