taro(ts)编写小程序内置组件类型异常的问题

发布于 2022-09-12 13:27:32 字数 969 浏览 14 评论 0

业务背景

react仅限于使用,函数式组件以及hooks都很少用的那种.今天开始学习taro编写小程序

遇到的问题

下面这个组件是正常的

import React from 'react';
import { View } from '@tarojs/components';

export default class Index extends React.Component {
  render() {
    return (
      <View className='container'>
        hello taro
      </View>
    )
  } 
}

但是当我在文件顶部加上下面这行代码后,render函数中的View组件就报错了

import Taro from '@tarojs/taro';

错误截图
image.png
错误内容

TS2786: 'View' cannot be used as a JSX component.   Its element type 'ReactElement<any, any> | Component<ViewProps, any, any> | null' is not a valid JSX element.     Type 'Component<ViewProps, any, any>' is not assignable to type 'Element | ElementClass | null'.       Type 'Component<ViewProps, any, any>' is not assignable to type 'ElementClass'.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文