【问题标题】:react-fabricjs package doesn't workreact-fabricjs 包不起作用
【发布时间】:2018-09-02 22:43:32
【问题描述】:

我将在 React 项目中使用 Fabric.js。 我找到了 react-fabricjs 包并将其导入到项目中。

但它不起作用。

import React, { Component } from 'react';
import { fabric, Canvas, Circle, Image, Path, Text } from 'react-fabricjs';
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import { ActionCreators } from '../../redux/action'
import { push } from 'react-router-redux';
import { Router, Route, browserHistory, IndexRoute } from 'react-router';
import Notifications, {notify} from 'react-notify-toast';
import * as controller from '../../lib/controller'

import FileDrop from '../../component/FileDrop'
import firebase from 'firebase'
import FeedbackList from '../../component/FeedbackList'
import FirebaseMedia from '../../component/FeedbackList/media'
import DeleteForm from '../../component/Delete'


require('./index.css')
const sample_word = require('../../resource/images/sample-word.png')
const sample_video = require('../../resource/images/sample-video.png')
const sample_audio = require('../../resource/images/sample-audio.png')
const sample_pdf = require('../../resource/images/sample-pdf.png')
const loadingIcon = require('../../resource/gif/loading.svg')
...
<div className="full-item">
     <div className="full-item-inner">
          <canvas id="c"
                  ref="canvas"
                  width="1000"
                  height="1000">
                  <Image ref="image"
                        imgElement={document.getElementById('my-image')}
                        width={100}
                        height={100}/>
          </canvas>
          <img id="my-image" alt="" src={this.state.workContent} />
     </div>
</div>

我不熟悉 React/Redux。 请帮我。

【问题讨论】:

    标签: reactjs redux fabricjs


    【解决方案1】:

    我找到了为什么 react-fabricjs 包对我不起作用的原因。 因为 react-fabricjs 不支持 Typescript,所以我无法从该包中导入模块。

    所以我决定在我的项目中使用 @types/fabric

    npm install --save @types/fabric
    

    希望对其他开发者有所帮助。

    【讨论】:

    • 你好,如果我们简单地安装它会不会被唤醒。对我来说它不起作用
    • 那么您能提供更详细的问题吗? @Dinesh
    • @jini Uncaught TypeError: Cannot read property 'bool' of undefined ,我正在进入控制台
    猜你喜欢
    • 2013-03-04
    • 2020-01-17
    • 1970-01-01
    • 2017-08-19
    • 2018-07-13
    • 2018-09-13
    • 2016-04-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多