我想做的是循环当前的帖子类型和“产品”,但我正在努力处理这些类型。所以我收到以下错误:
“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) 使用Vite部署 Web 应用程序时,我无法部署 .js 文件。得到以下问题。
$ vite build
vite v2.8.6 building for production...
**\<script src="/index.js"\> in "/index.html" can't be bundled without type="module" attribute**
transforming...
Run Code Online (Sandbox Code Playgroud)
我无法在脚本中使用,type=module
因为我不需要导入代码。如果我使用的话就会出现错误。
如果有人可以帮忙的话。
我尝试使用脚本type=module
但出现错误。有什么方法可以在不使用 的情况下使用Vitetype=module
进行部署吗?
当引用 HTML 表单中的元素时,我经常使用 name 属性的名称/值。所以,如果表单的名称是“form01”,我指的是表单的书写document.forms.form01
。这是一个例子:
let title = document.forms.form01.title;
console.log(title.value);
Run Code Online (Sandbox Code Playgroud)
<form name="form01">
<input type="text" name="title" value="Hello World">
</form>
Run Code Online (Sandbox Code Playgroud)
这是一个 HTMLCollection,但在DOM 标准 #interface-htmlcollectiondocument.forms
的文档中,它没有提到在这样的集合上直接使用名称作为属性(我认为它被称为“命名属性”)的可能性 -就像我用来指代表单元素时一样。相反,文档实际上指出这是“历史文物”——那么,我应该避免使用它吗?document.forms.form01
你能帮我找到这方面的文档吗?要么它是一个可以使用的(好)功能,要么它是应该避免的东西。
我需要帮助来完成此练习:
数组方法
实现一个uncompletedNotes
函数,在给定注释数组的情况下,仅返回未完成的注释。如果所有存在的待办事项都将完成标志设置为 true,则认为注释已完成。
这就是我所做的:
function uncompletedNotes(notes) {
let result = []
notes.forEach(element => {
if (element.todos.done == false) {
result.push(element);
}
});
return result;
}
const notes = [{
id: 1,
description: 'Workout program',
todos: [{
id: 1,
name: 'Push ups - 10 x 3',
done: false
},
{
id: 2,
name: 'Abdominals - 20 x 3',
done: true
},
{
id: 3,
name: 'Tapis Roulant - 15min',
done: true
}
]
},
{
id: 2,
description: …
Run Code Online (Sandbox Code Playgroud)javascript ×4
arrays ×1
deployment ×1
dom ×1
html ×1
production ×1
reactjs ×1
standards ×1
typescript ×1
vite ×1