02-Taro页面编写和传值
上回说到Taro打造hello-world应用。废话不多说,直接上肉菜
State局部状态
export default class Index extends Component {
config = {
navigationBarTitleText: '首页'
}
state = {
name: "hello 前端骚年"
}
render () {
const { name } = this.state
return (
<View className='index'>
<Text>{name}</Text>
</View>
)
}
}
组件编写和传值
mkdir -p src/components/child
cd src/components/child
touch index.jsx
编写组件,代码如下
import Taro, { Component } from '@tarojs/taro'
import PropTypes from 'prop-types'
import { View, Text } from '@tarojs/components'
export default class Child extends Component {
propTypes = {
childName: PropTypes.string
}
defaultProps = {
childName: