我想做的是循环当前的帖子类型和“产品”,但我正在努力处理这些类型。所以我收到以下错误:
“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) 我忙于一家网店,我想回应今天有多少订单需要交付
我有一个循环,其中包含以下代码:
$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 的值?
请问有人可以帮我吗?