尝试在 ng5 项目中使用 node-vibrant。 所以我尝试导入 npm 包
import Vibrant = require('node-vibrant');
//要么
从 'node-vibrant' 导入 Vibrant ;
//要么
从 'node-vibrant/src/vibrant' 导入 * 作为 Vibrant;
//要么
import Vibrant = require('node-vibrant/src/vibrant')
没有成功 。
我试着像那样使用它
declare var Vibrant :any;
Vibrant.from('this.toPlayRadio.pic').getPalette(function(err, palette) {
console.log(palette);
});
but it return an error when use it
TypeError: this._canvas is undefined
Stack trace:
TypeError: this._canvas is undefined
BroswerImage.prototype.remove@http://localhost:8080/node_modules/node-vibrant/dist/vibrant.js:12676:9
Vibrant.prototype.getPalette/<@http://localhost:8080/node_modules/node-vibrant/dist/vibrant.js:7103:43
finallyHandler@http://localhost:8080/node_modules/node-vibrant/dist/vibrant.js:2593:15
tryCatcher@http://localhost:8080/node_modules/node-vibrant/dist/vibrant.js:5910:16
[22]_settlePromiseFromHandler@http://localhost:8080
...
and this is my tsconfig.json file
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"noStrictGenericChecks": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true
}
and i use
"typescript": "^2.6.2",
so i am wondering how to use node-vibrant with ng5 , and how to correctly import it in ts class
进口('节点活力')。然后((活力)=> {
//代码在这里
})
@amirping ,我认为问题在于库无法加载图像。 在 #61 中,请参阅此提交。
@amirping
我已经设法使用它如下 -
const vibrant = require('node-vibrant');
使用 v 3.1.1
,我们可以确认使用import Vibrant = require('node-vibrant')
有效吗?
@拐杖
尝试了import Vibrant = require('node-vibrant')
和const Vibrant = require('node-vibrant')
前者给出#90。 后者给出#85。
感谢测试。 这周我会仔细看看
最有用的评论
@拐杖
尝试了
import Vibrant = require('node-vibrant')
和const Vibrant = require('node-vibrant')
前者给出#90。 后者给出#85。