如何在ionic项目中使用fabric js(html5-Canvas Library)自定义构建

iih3973s  于 2022-12-08  发布在  Ionic
关注(0)|答案(4)|浏览(118)

I am working in ionic application that enable to create graphics. I am using fabric js letest version 3.2.0 and want ot use touch gesture.
I try to clone fabric js repository into my pc and try to build custom build using following command :

node build.js modules=ALL

So, build is successful in dist folder, but I don't know how to install it in ionic.
Please help me.

v09wglhw

v09wglhw1#

After compare all file in node-module/fabric and my custom build. and I got that both are same. So I put this answer for help.
Step :

  1. install letest fabric js using cmd : npm install fabric --save
  2. download custom build from fabric js site : http://fabricjs.com/build/
  3. open : ionic-project-folder/node modules/fabric/
  4. replace dist folder Placed inside above path with downloaded custom build (dist folder)
  5. re-serve project.
    If any other solution is possible (like publishing into npm and install) then Please mention.
kfgdxczn

kfgdxczn2#

这是一个指向Ionic的API的链接,用于与Crashlytics工具包交互:https://ionicframework.com/docs/v3/native/crashlytics/。这应该有让你的离子应用程序与Crashlytics集成所需的说明。

vfwfrxfs

vfwfrxfs3#

通过npm安装

npm i fabric

更多详细信息请访问
https://www.npmjs.com/package/fabric

4jb9z9bj

4jb9z9bj4#

对于我的情况,我使用一个自定义构建结构js版本5.2.4和一个Ionic 6应用程序。
1.如果使用npm uninstall fabric将fabric js安装在项目中,请卸载它
1.从Fabric js站点下载您的自定义构建:http://fabricjs.com/build/
1.将下载的文件添加到public目录下,例如public/libs/fabric/fabric.min.js
1.在App.js

useEffect(() => {
        const script = document.createElement('script');
        // You may have to replace this code with your path.
        script.src = "libs/fabric/fabric.min.js";
        script.async = true;
        document.body.appendChild(script);
        return () => {
            document.body.removeChild(script);
        }
    }, []);

1.重新服务项目。
1.现在fabric应该可以从window.fabric获得
注意。
编辑器还添加了一些代码到我的tsconfig.json

"include": [
    "src",
    "public/libs" // This code
  ]

我不知道它是做什么的,但它工作正常,所以我离开了它。

相关问题