页面上未定义的变量,使用操纵符的功能

问题描述 投票:0回答:1

当我在代码中运行它时,它说dottt是未定义的,但是为什么它正确地吸收了pdfcitystatezipselector。如果我将dottt替换为字符串文字,则效果很好。

const pdfcitystatezipselector = 'body > div:nth-child(1) > div:nth-child(6) > span';
  const dottt = "111111";

  await page.$eval(pdfdotselector, (element1, dotttt) => {


    element1.innerHTML = dottt;
  });

请不要删除此帖子。我看到其他类似的帖子。但看不到有什么方法可以解决我的问题。他们相信他们会更多地使用page.evaluate,而不是page.eval。

javascript bots eval puppeteer headless
1个回答
0
投票

您需要将dotttt参数传递给$eval函数:

const pdfcitystatezipselector = 'body > div:nth-child(1) > div:nth-child(6) > span';
const dottt = "111111";

await page.$eval(pdfdotselector, 
    (element1, dotttt) => {
       element1.innerHTML = dottt;
    },
    dotttt); // here
© www.soinside.com 2019 - 2024. All rights reserved.