3

我无法使用 jsdom 获得颜色的计算样式值:

require("jsdom").env({
    html: '<html><head><style> html { color: red; } </style></head><body></body></html>',
    done: function(errors, window) {

        console.log('color: "'+window.getComputedStyle(window.document.body).color+'"');
    }
});

前面的测试返回 "" 而不是 "rgb(255, 0, 0)" 或 "red" ...
(请注意,这在浏览器中可以正常工作)

我错过了什么吗?

4

1 回答 1

5

似乎jsdom没有为getComputedStyle.

如果你得到html标签的计算样式,它应该可以工作。

于 2015-04-25T11:48:13.983 回答