react-fabricjs包不起作用

时间:2018-03-24 10:10:55

标签: reactjs redux fabricjs

我将把Fabric.js用于React项目。 我找到了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。 请帮我。

1 个答案:

答案 0 :(得分:1)

好吧,我发现为什么react-fabricjs包在我的结尾不起作用。 因为react-fabricjs不支持Typescript,所以我无法从该包导入模块。

所以我决定将 @ types / fabric 用于我的项目。

npm install --save @types/fabric

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