如何将createjs库包含到reactjs项目中 [英] how to Include createjs library into reactjs project

查看:291
本文介绍了如何将createjs库包含到reactjs项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在基于reactjs上创建一个基于画布的应用程序,它需要Createjs库,我是Reactjs的新手,我还不知道该怎么做,所以我尝试了两种方法,一种是使用NPM安装,另一种是我将js放在一个文件夹中,尝试从那里导入,但是对我没有用,这是我的代码

Hi I am creating an app on reactjs, which is canvas based, It require Createjs library, I am new for Reactjs I am not getting perfect idea how do this so I tried 2 ways one is using NPM install and other one is I kept my js into one folder and tries to import from there but nothing works for me, here my code

方法1,安装npm,

从'createjs'导入createjs;

way 1 with npm install,
import createjs from 'createjs';

方法2导入下载的js文件,

从'../assets/js/createjsmin'导入createjs。

way 2 import downloaded js file,
import createjs from '../assets/js/createjsmin';

我随机尝试了

import * as from'../ assets / js / createjsmin';

randomly I tried
import * as createjs from '../assets/js/createjsmin';

但对我没有任何作用

推荐答案

我将相对路径添加到index.html并将Createjs库代码放入使用window.createjs的componentWillMount(),不知道,但我认为它可以在react中添加所有随机库。

I add relative path to index.html and got Createjs library code into componentWillMount() using window.createjs, dn't know but I feel it can work to add all ramdom libraries in react.

这篇关于如何将createjs库包含到reactjs项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆