如何在 Chrome 开发工具中运行 javascript 应用程序并将 JSON 文件作为参数?

问题描述

我的 app.js 中有一个函数,我希望能够在 Chrome 开发工具中使用它,但是如何在开发工具中调用函数并将 JSON 文件作为第一个参数?

const appFilter = (json,city) => {
  const filterednames = json
    .filter((obj) => {
      return obj.location === city;
    })
    .map((obj2) => {
      return obj2.name;
    });
  console.log(filterednames);
  return filterednames;
};


或者有其他方法可以通过命令行执行此操作吗?我看不到在命令行中使用 node app.js

编辑:更多信息,我可以通过 require('./app.js') 在 Node 中打开我的文件 但我希望能够在 Node 中使用不同的输入调用函数 appFilter() 但我收到以下错误Uncaught ReferenceError: appFilter is not defined

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)