小编Gur*_*rdt的帖子

反应类型错误“无法分配给‘never’类型的参数”

我想做的是循环当前的帖子类型和“产品”,但我正在努力处理这些类型。所以我收到以下错误:

“Record<string,any>[]”类型的参数不可分配给“never”类型的参数。

关于这一部分:

...pages.map((page) => ({
Run Code Online (Sandbox Code Playgroud)

我的代码:

  const pages = useSelect((select) => {
    const editor = select("core/editor");
    const currentPostType: string = editor.getCurrentPostType();
    const selectablePostTypes = [currentPostType, "products"];

    const postList = [];

    selectablePostTypes.forEach((singlePostType) => {
      const records: Record<string, any>[] = select("core").getEntityRecords(
        "postType",
        singlePostType
      );

      postList.push(records);
    });
  });

  // Make dropdown of pagesOptions
  const pagesOptions = [
    ...[
      {
        value: "0",
        label: __("No page selected", "demosite"),
      },
    ],
    ...pages.map((page) => ({
      value: page.id,
      label: page.title,
    })),
  ];
Run Code Online (Sandbox Code Playgroud)

添加有效的代码:

  const pages = useSelect((select) …
Run Code Online (Sandbox Code Playgroud)

javascript typescript reactjs

8
推荐指数
1
解决办法
1931
查看次数

array_count_values 我想回显一个特定的键值

我忙于一家网店,我想回应今天有多少订单需要交付

我有一个循环,其中包含以下代码:

$winkels[] = $vendor->id;
Run Code Online (Sandbox Code Playgroud)

很好,因为我做了以下代码:

echo '<pre>'.print_r(array_count_values($winkels),true).'</pre>';
Run Code Online (Sandbox Code Playgroud)

比我得到的结果:

Array
(
   [63] => 1
   [45] => 1
   [85] => 1
   [59] => 1
)
Run Code Online (Sandbox Code Playgroud)

结果很好,但我如何回应 id: 63 的值?

请问有人可以帮我吗?

php wordpress loops vendor woocommerce

4
推荐指数
1
解决办法
713
查看次数

标签 统计

javascript ×1

loops ×1

php ×1

reactjs ×1

typescript ×1

vendor ×1

woocommerce ×1

wordpress ×1