Commit d5d51624 authored by SuYK's avatar SuYK

End

parent 893e1a69
hello world 组件兼容H5和小程序,
\ No newline at end of file
组件位置:src\components\DateTimePicker\DateTimePicker.tsx
文件说明: src\components\DateTimePicker\DateType 文件控制时间格式
h5运行指令:pnpm dev:h5
小程序运行指令: pnpm dev:weapp 、然后用微信开发者工具打开dist目录
import { Component, PropsWithChildren } from 'react' import { Component, PropsWithChildren } from 'react'
import { View } from '@tarojs/components' import { View } from '@tarojs/components'
import formatDate from '../../utils/DateFun' import formatDate from '../../utils/DateFun'
import './myDate.scss' import './DateTimePicker.scss'
import DATETYPE from './DateType' import DATETYPE from './DateType'
...@@ -15,7 +15,7 @@ interface StateType { ...@@ -15,7 +15,7 @@ interface StateType {
transientYear: number transientYear: number
} }
export default class MyDate extends Component<PropsWithChildren | any> { export default class DateTimePicker extends Component<PropsWithChildren | any> {
state: Readonly<StateType> = { state: Readonly<StateType> = {
date: new Date(), date: new Date(),
......
import { Component, PropsWithChildren } from 'react' import { Component, PropsWithChildren } from 'react'
import { View, Text, Input } from '@tarojs/components' import { View, Text, Input } from '@tarojs/components'
import MyDate from '../../components/myDate/myDate' import DateTimePicker from '../../components/DateTimePicker/DateTimePicker'
import './index.scss' import './index.scss'
interface State { interface State {
...@@ -38,7 +38,7 @@ export default class Index extends Component<PropsWithChildren> { ...@@ -38,7 +38,7 @@ export default class Index extends Component<PropsWithChildren> {
<Text>日期:</Text> <Text>日期:</Text>
<Input type='text' placeholder='选择日期' value={this.state.date} disabled onClick={this.ChangeIsShow} /> <Input type='text' placeholder='选择日期' value={this.state.date} disabled onClick={this.ChangeIsShow} />
</View> </View>
{this.state.isShow && <MyDate showDate={this.showDate} />} {this.state.isShow && <DateTimePicker showDate={this.showDate} />}
</View> </View>
) )
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment