【问题标题】:Intellij 2016.1.4 and React render() methodIntellij 2016.1.4 和 React render() 方法
【发布时间】:2018-02-25 09:05:06
【问题描述】:

我在 React 组件中有一个渲染方法:

import * as React from "react";
import MediaService from "./service/MediaService";
import ComponentLifecycle = require("@types/react");
import DOMHelper from "../helpers/DOMHelper";

export default class PictureTaker extends React.Component implements ComponentLifecycle {
    // Not important

    render () {
        return (
          <article>
              <video id="ra-video">
                  Video not supported
              </video>
          </article>
        );
    }
}

它将id 标记为attribute id is not allowed here,但是好的 - 我明白了。我想重构代码以将&lt;video&gt; 提取到另一个组件:

import * as React from "react";

export default class VideoPlayer extends React.Component {
    constructor () {
        super();
    }

    render () {
        return (
            <video id="ra-video">
                Video not supported
            </video>
        );
    }
}

但它与消息中断:unresolved type video。这是它的样子:

VideoPlayer 的代码是从PictureTaker 粘贴的,这让我很吃惊。我有React:

还有React DOM:

Settings / Languages and frameworks / Javascript / Libraries 内。你看到我犯了什么错误吗?提前感谢您的每一个回答。

【问题讨论】:

    标签: javascript reactjs intellij-idea react-dom intellij-idea-2016


    【解决方案1】:

    天哪,我找到了解决方案...我使用了.ts 扩展名而不是.tsx。 是VideoPlayer.ts,应该是VideoPlayer.tsx,我的错。

    【讨论】:

    • 你可以删除问题“typo/non-preproducible”
    • @pvg 也许吧,但对于 React 新手来说,这是一个像我一样犯错误的机会,它可以防止他们像我一样浪费一个小时。
    • 真的没有任何机会,就像有可能重复 any 错字一样。这就是该标志存在的原因。
    【解决方案2】:

    什么是视频?您必须将 video.js 与 React.js 一起导入才能使用

    【讨论】:

      猜你喜欢
      • 2022-12-04
      • 2012-04-19
      • 1970-01-01
      • 2020-12-09
      • 2016-07-27
      • 2017-01-18
      • 2016-06-07
      • 2016-01-19
      • 2023-03-28
      相关资源
      最近更新 更多