change to class

yhy
FrozenArcher 2024-03-03 02:53:49 +08:00
parent 6f896c8695
commit 14b302bd1a
3 changed files with 27 additions and 11 deletions

View File

@ -27,7 +27,12 @@ export default defineConfig(async (merge, { command, mode }) => {
}
},
framework: 'react',
compiler: 'webpack5',
compiler: {
type: 'webpack5',
prebundle: {
exclude: ['taro-ui']
}
},
cache: {
enable: false // Webpack 持久化缓存配置建议开启。默认配置请参考https://docs.taro.zone/docs/config-detail#cache
},
@ -58,6 +63,7 @@ export default defineConfig(async (merge, { command, mode }) => {
}
},
h5: {
esnextModules: ['taro-ui'],
publicPath: '/',
staticDirectory: 'static',
output: {

View File

@ -1,5 +1,6 @@
import { PropsWithChildren } from 'react'
import { useLaunch } from '@tarojs/taro'
import 'taro-ui/dist/style/index.scss'
import './app.scss'
function App({ children }: PropsWithChildren<any>) {

View File

@ -1,16 +1,25 @@
import { View, Text } from '@tarojs/components'
import { useLoad } from '@tarojs/taro'
import './index.scss'
import { Component, ReactNode } from 'react'
export default function Index() {
class Index extends Component {
state = {
msg: "Hello World!"
}
useLoad(() => {
console.log('Page loaded.')
})
onReady() {
console.log("Index is ready");
}
render(): ReactNode {
return (
<View className='index'>
<Text>Hello world!</Text>
<View>
<Text>
{this.state.msg}
</Text>
</View>
)
}
}
export default Index