【发布时间】:2018-11-05 03:46:21
【问题描述】:
我正在尝试在 Array.from () 上使用内置的 map() 函数,该函数使用 Puppeteer 返回一些元素。
下面是代码:
let res = await page.evaluate(elementPath => {
return Array.from(document.querySelectorAll(elementPath), (cin, index) => {
return {
cs: `state is ${this.s}`, // returns state is undefined
cinemaIndex: index,
cinemaId: cin.getAttribute('data-id'),
cinemaName: cin.getAttribute('data-name'),
cinemaURL: cin.getAttribute('data-url'),
};
}, {
s: 'NSW'
});
}, `div[data-state=${cinemaState}] div.top-select-option a.eccheckbox`, cinemaState);
我无法使用变量 s 或 cinemaState 分配 cs。
想知道你有没有解决办法
【问题讨论】:
标签: javascript node.js google-chrome-devtools puppeteer headless-browser