Javascript 是否可以在喷漆工作集中使用npm安装的模块?
我在文件中定义了一个Javascript 是否可以在喷漆工作集中使用npm安装的模块?,javascript,reactjs,npm,css-houdini,css-paint-api,Javascript,Reactjs,Npm,Css Houdini,Css Paint Api,我在文件中定义了一个paintWorklet,我想在其中使用它来进行一些颜色处理。但是,导入库(在npm安装之后)会停止工作集的工作。以下是我所拥有的: index.html(在中): 有没有办法将库导入工作集?如果没有,那么执行某些任务将变得相当棘手 <script> CSS.paintWorklet.addModule('%PUBLIC_URL%/testPaint.js'); </script> const chroma = require("chr
paintWorklet
,我想在其中使用它来进行一些颜色处理。但是,导入库(在npm安装之后)会停止工作集的工作。以下是我所拥有的:
index.html(在
中):
有没有办法将库导入工作集?如果没有,那么执行某些任务将变得相当棘手
<script>
CSS.paintWorklet.addModule('%PUBLIC_URL%/testPaint.js');
</script>
const chroma = require("chroma-js"); // doesn't work
import chroma from "chroma-js"; // doesn't work
registerPaint(
"testPaint",
class {
static get inputProperties() {
return ["--bubble-size", "--bubble-color"];
}
paint(ctx, geom, properties) {
//stuff
}
}
)