ng5 ํ๋ก์ ํธ์์ node-vibrant๋ฅผ ์ฌ์ฉํ๋ ค๊ณ ํฉ๋๋ค. ๊ทธ๋์ npm ํจํค์ง๋ฅผ ๊ฐ์ ธ ์ค๋ ค๊ณ ํฉ๋๋ค.
import Vibrant = require('๋ ธ๋-๋ฐ์ด๋ธ๋ฐํธ');
//๋๋
'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
import('๋
ธ๋-๋ฐ์ด๋ธ๋ฐํธ').then((๋ฐ์ด๋ธ๋ฐํธ) => {
//์ฌ๊ธฐ์ ์ฝ๋
})
@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๋ฅผ ์ ๊ณตํฉ๋๋ค.