我正在嘗試將背景顏色作為參數(shù)傳遞給函數(shù),如下面的代碼所示:const loc = await page.waitForSelector("#Login");const style = 'background-color';const thecssStyle = await page.evaluate(el => window.getComputedStyle(el).getPropertyValue(style),loc);console.log("Print :"+thecssStyle);這不起作用,我收到以下錯(cuò)誤:UnhandledPromiseRejectionWarning:錯(cuò)誤:評(píng)估失?。篟eferenceError:未定義樣式但是,如果我直接傳遞背景顏色,如下所示,它絕對(duì)可以正常工作:const loc = await page.waitForSelector("#Login");const thecssStyle = await page.evaluate(el => window.getComputedStyle(el).getPropertyValue('background-color'),loc);console.log("Print :"+thecssStyle);我想將背景顏色作為參數(shù)傳遞,而不是直接傳遞它我該怎么做?
無(wú)法將參數(shù)傳遞給評(píng)估函數(shù)
千萬(wàn)里不及你
2022-10-27 14:48:38