软艺坊 2024-06-03 15:47 采纳率: 90%
浏览 13
已结题

taro react编写微信小程序使用 useState, async函数时所有页面全部空白,只有标题和底部tab栏,没有任何报错信息。

taro react编写微信小程序 在pages/airportList/airportList.tsx中使用 useState, async函数时所有页面全部空白,只有标题和底部tab栏,没有任何报错信息。

airportList.tsx


```typescript
import './airportList.less';
import { useState, useEffect } from 'react';
import { View, Text } from '@tarojs/components';
import { useLoad } from '@tarojs/taro';

export default function AirpostList() {

  // const [list, setList] = useState([]);

  // const getAirpostList = async () => {
  // }

  // useEffect(() => {
  //   getAirpostList();
  //   return () => {

  //   }
  // }, []);

  useLoad(() => {
    console.log('Page loaded.');
  });

  return (
    <View className='index'>
      <Text>Hello world!</Text>
    </View>
  );
}





app.config.ts
export default defineAppConfig({
  pages: [
    'pages/index/index',
    'pages/order/order',
    'pages/airportList/airportList'
  ],
  window: {
    backgroundColor: '#eeeeee',
    backgroundTextStyle: 'light',
    navigationBarTitleText: '远方',
    navigationBarTextStyle: 'white',
    navigationBarBackgroundColor: '#ffffff',
  },
  tabBar: {
    color: '#7F8389',
    selectedColor: '#5495E6',
    backgroundColor: '#ffffff',
    borderStyle: 'black',
    position: 'bottom',
    list: [
      {
        pagePath: 'pages/index/index',
        text: '首页',
        iconPath: 'assets/images/index-unselected.png',
        selectedIconPath: 'assets/images/index-selected.png'
      },
      {
        pagePath: 'pages/order/order',
        text: '我的订单',
        iconPath: 'assets/images/order-unselected.png',
        selectedIconPath: 'assets/images/order-selected.png'
      }
    ]
  }
});


```

  • 写回答

3条回答 默认 最新

  • 软艺坊 2024-06-03 15:57
    关注

    发现问题了taro添加页面后要重启才能正确显示

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 6月11日
  • 已采纳回答 6月3日
  • 创建了问题 6月3日