Compiler errors
动画重复
An element can only have one 'animate' directive动画无效位置
An element that uses the `animate:` directive must be the only child of a keyed `{#each ...}` block动画缺失键
An element that uses the `animate:` directive must be the only child of a keyed `{#each ...}` block. Did you forget to add a key to your each block?属性_contenteditable_动态
'contenteditable' attribute cannot be dynamic if element uses two-way binding属性_contenteditable_missing
'contenteditable' attribute is required for textContent, innerHTML and innerText two-way bindings属性重复
属性需要唯一
属性_空简写
Attribute shorthand cannot be empty属性无效事件处理器
Event attribute must be a JavaScript expression, not a string属性无效多次
'multiple' attribute must be static if select uses two-way binding属性无效名称
'%name%' is not a valid attribute name属性无效的序列表达式
Sequence expressions are not allowed as attribute/directive values in runes mode, unless wrapped in parentheses属性无效类型
'type' attribute must be a static text value if input uses two-way binding属性未引号序列
Attribute values containing `{...}` must be enclosed in quote marks, unless the value only contains the expression绑定组无效表达式
`bind:group` can only bind to an Identifier or MemberExpression绑定组无效的片段参数
Cannot `bind:group` to a snippet parameter绑定无效表达式
Can only bind to an Identifier or MemberExpression or a `{get, set}` pair绑定无效名称
`bind:%name%` is not a valid binding`bind:%name%` is not a valid binding. %explanation%绑定无效括号
`bind:%name%={get, set}` must not have surrounding parentheses绑定无效目标
`bind:%name%` can only be used with %elements%绑定无效值
Can only bind to state or props可绑定无效位置
`$bindable()` can only be used inside a `$props()` declarationblock_duplicate_clause
%name% cannot appear more than once within a blockblock_invalid_continuation_placement 阻止无效的延续放置
{:...} block is invalid at this position (did you forget to close the preceding element or block?)block_invalid_elseif
'elseif' 应该是 'else if'
无效放置
{#%name% ...} block cannot be %location%block_unclosed
块被留下打开
block_unexpected_character
Expected a `%character%` character immediately following the opening bracketblock_unexpected_close
未预期的块关闭标签
组件无效指令
This type of directive is not valid on componentsconst_tag_cycle
Cyclical dependency detected: %cycle%const_tag_invalid_expression
{@const ...} must consist of a single variable declarationconst_tag_invalid_placement
`{@const}` must be the immediate child of `{#snippet}`, `{#if}`, `{:else if}`, `{:else}`, `{#each}`, `{:then}`, `{:catch}`, `<svelte:fragment>`, `<svelte:boundary` or `<Component>`常量赋值
无法分配给%thing%
常量绑定
无法绑定到%thing%
css 空声明
声明不能为空
css_expected_identifier
Expected a valid CSS identifiercss 全局块无效组合器
A `:global` selector cannot follow a `%name%` combinatorcss 全局块无效声明
A top-level `:global {...}` block can only contain rules, not declarationscss 全局块无效列表
A `:global` selector cannot be part of a selector list with entries that don't contain `:global`以下 CSS 无效:
:global, x {
y {
color: red;
}
}这是混合了一个:global块,这意味着“这里面的所有内容都是未限定的”,与一个限定的选择器(在这种情况下为x)。因此,无法将内部选择器(在这种情况下为y)转换为满足这两个要求的东西。因此,您必须将其拆分为两个选择器:
:global {
y {
color: red;
}
}
x y {
color: red;
}css 全局块无效修饰符
A `:global` selector cannot modify an existing selectorcss 全局块无效修饰符开始
A `:global` selector can only be modified if it is a descendant of other selectorscss 全局块无效定位
A `:global` selector cannot be inside a pseudoclasscss 全局无效位置
`:global(...)` can be at the start or end of a selector sequence, but not in the middlecss 全局无效选择器
`:global(...)` must contain exactly one selectorcss 全局无效选择器列表
`:global(...)` must not contain type or universal selectors when used in a compound selectorcss 嵌套选择器无效位置
Nesting selectors can only be used inside a rule or as the first selector inside a lone `:global(...)`css_selector_invalid
无效选择器
css_type_selector_invalid_placement
`:global(...)` must not be followed by a type selectordebug_tag_invalid_arguments
{@debug ...} arguments must be identifiers, not arbitrary expressions声明重复
`%name%` has already been declared声明重复模块导入
Cannot declare a variable with the same name as an import inside `<script module>`派生无效出口
Cannot export derived state from a module. To expose the current derived value, export a function returning its value指令无效值
Directive value must be a JavaScript expression enclosed in curly braces指令名称缺失
`%type%` name cannot be empty美元绑定无效
The $ name is reserved, and cannot be used for variables and imports美元前缀无效
The $ prefix is reserved, and cannot be used for variables and imports每个项目无效分配
Cannot reassign or bind to each block argument in runes mode. Use the array and index variables instead (e.g. `array[i] = value` instead of `entry = value`, or `bind:value={array[i]}` instead of `bind:value={entry}`)在传统模式下,可以重新分配或绑定到每个块参数本身:
<script>
let array = [1, 2, 3];
</script>
{#each array as entry}
<!-- reassignment -->
<button on:click={() => entry = 4}>change</button>
<!-- binding -->
<input bind:value={entry}>
{/each}这结果出现了 bug 和不稳定,尤其是在处理派生值(例如 array.map(...))时,因此在 runes 模式下被禁止。您可以通过使用索引来达到相同的效果:
<script>
let array = $state([1, 2, 3]);
</script>
{#each array as entry, i}
<!-- reassignment -->
<button onclick={() => array[i] = 4}>change</button>
<!-- binding -->
<input bind:value={array[i]}>
{/each}无效位置
`$effect()` can only be used as an expression statement元素无效的闭合标签
`</%name%>` attempted to close an element that was not open元素无效关闭标签自动闭合
`</%name%>` attempted to close element that was already automatically closed by `<%reason%>` (cannot nest `<%reason%>` inside `<%name%>`)元素未闭合
`<%name%>` 未关闭
事件处理程序无效组件修改器
Event modifiers other than 'once' can only be used on DOM elements事件处理程序无效修饰符
Valid event modifiers are %list%事件处理程序无效的修饰符组合
The '%modifier1%' and '%modifier2%' modifiers cannot be used together预期属性值
期望的属性值
预期块类型
Expected 'if', 'each', 'await', 'key' or 'snippet'expected_identifier
期望一个标识符
expected_pattern
Expected identifier or destructure patternexpected_token
期望的标记 %token%
expected_whitespace
期望的空白
实验异步
Cannot use `await` in deriveds and template expressions, or at the top level of a component, unless the `experimental.async` compiler option is `true`导出未定义
`%name%` 未定义
全局引用无效
`%name%` is an illegal variable name. To reference a global variable called `%name%`, use `globalThis.%name%`主机无效位置
`$host()` can only be used inside custom element component instances非法元素属性
`<%name%>` does not support non-event attributes or spread attributes导入_svelte 内部禁止
Imports of `svelte/internal/*` are forbidden. It contains private runtime code which is subject to change without notice. If you're importing from `svelte/internal/*` to work around a limitation of Svelte, please open an issue at https://github.com/sveltejs/svelte and explain your use case检查迹生成器
`$inspect.trace(...)` cannot be used inside a generator function检查无效放置
`$inspect.trace(...)` must be the first statement of a function body无效参数使用
The arguments keyword cannot be used within the template or at the top level of a componentJavaScript 解析错误
%message%
遗产_await_invalid
Cannot use `await` in deriveds and template expressions, or at the top level of a component, unless in runes mode遗产导出无效
Cannot use `export let` in runes mode — use `$props()` instead遗产属性无效
Cannot use `$$props` in runes mode遗产式响应式语句无效
`$:` is not allowed in runes mode, use `$derived` or `$effect` instead遗产_rest_props_invalid
Cannot use `$$restProps` in runes modelet_directive_invalid_placement
`let:` directive at invalid position混合事件处理器语法
Mixing old (on:%name%) and new syntaxes for event handling is not allowed. Use only the on%name% syntax模块_非法默认导出
A component cannot have a default export节点无效放置
%message%. The browser will 'repair' the HTML (by moving, removing, or inserting elements) which breaks Svelte's assumptions about the structure of your components.HTML 限制某些元素出现的位置。如果发生违规,浏览器将以破坏 Svelte 对您组件结构假设的方式“修复”HTML。一些例子:
<p>hello <div>world</div></p>将导致<p>hello </p><div>world</div><p></p>(由于<div>自动关闭了<p>,因为<p>不能包含块级元素)<option><div>option a</div></option>将生成<option>option a</option>(移除了<div>)<table><tr><td>cell</td></tr></table>将导致<table><tbody><tr><td>cell</td></tr></tbody></table>(自动插入<tbody>)
选项无效值
Invalid compiler option: %details%options_removed
Invalid compiler option: %details%选项未识别
Unrecognised compiler option %keypath%props_duplicate
Cannot use `%rune%()` more than onceprops_id_invalid_placement
`$props.id()` can only be used at the top level of components as a variable declaration initializerprops_illegal_name
Declaring or accessing a prop starting with `$$` is illegal (they are reserved for Svelte internals)props_invalid_identifier
`$props()` can only be used with an object destructuring patternprops_invalid_pattern
`$props()` assignment must not contain nested properties or computed keysprops_invalid_placement
`$props()` can only be used at the top level of components as a variable declaration initializer反应声明周期
Cyclical dependency detected: %cycle%渲染标签无效调用表达式
Calling a snippet function using apply, bind or call is not allowed渲染标签无效表达式
`{@render ...}` tags can only contain call expressions渲染标签无效的传播参数
cannot use spread arguments in `{@render ...}` tags无效的 rune 参数
`%rune%` cannot be called with arguments无效的 rune 参数长度
`%rune%` must be called with %args%无效的运行时计算属性
Cannot access a computed property of a rune无效的 rune 名称
`%name%` 不是一个有效的符文
无效的符文扩散
`%rune%` cannot be called with a spread argument无效的 rune 使用
Cannot use `%rune%` rune in non-runes moderune_missing_parentheses
Cannot use rune without parenthesesrune_removed
The `%name%` rune has been removedrune_renamed
`%name%` is now `%replacement%`runes_mode_invalid_import
%name% cannot be used in runes mode脚本重复
A component can have a single top-level `<script>` element and/or a single top-level `<script module>` element脚本无效属性值
If the `%name%` attribute is supplied, it must be a boolean attribute脚本无效上下文
If the context attribute is supplied, its value must be "module"脚本保留属性
The `%name%` attribute is reserved and cannot be used槽属性重复
Duplicate slot name '%name%' in <%component%>槽属性无效
slot attribute must be a static value槽属性无效位置
Element with a slot='...' attribute must be a child of a component or a descendant of a custom element槽默认重复
Found default slot content alongside an explicit slot="default"槽元素无效属性
`<slot>` can only receive attributes and (optionally) let directives槽元素无效名称
slot attribute must be a static value槽元素无效名称默认
`default` is a reserved word — it cannot be used as a slot name槽片段冲突
Cannot use `<slot>` syntax and `{@render ...}` tags in the same component. Migrate towards `{@render ...}` tags completely片段冲突
Cannot use explicit children snippet at the same time as implicit children content. Remove either the non-whitespace content or the children snippet block无效导出片段
An exported snippet can only reference things declared in a `<script module>`, or other exportable snippets它可以从一个 <script module> 块中导出代码片段,但前提是它不引用非模块级别的 <script> 中定义的任何内容。例如,你不能这样做...
<script module>
export { greeting };
</script>
<script>
let message = 'hello';
</script>
{#snippet greeting(name)}
<p>{message} {name}!</p>
{/snippet}...因为greeting引用了message,后者定义在第二个<script>中。
片段无效的剩余参数
Snippets do not support rest parameters; use an array instead片段参数分配
Cannot reassign or bind to snippet parameter片段阴影属性
This snippet is shadowing the prop `%prop%` with the same name状态字段重复
`%name%` has already been declared on this class一个将 $state 或 $derived 符文赋值给类字段的操作被视为 状态字段声明。声明可以在类体中发生...
class class CounterCounter {
Counter.count: numbercount = function $state<0>(initial: 0): 0 (+1 overload)
namespace $state
$state(0);
}...或是在构造函数内部...
class class CounterCounter {
constructor() {
this.Counter.count: anycount = function $state<0>(initial: 0): 0 (+1 overload)
namespace $state
$state(0);
}
}...但只能发生一次。
状态字段无效分配
Cannot assign to a state field before its declaration无效导出状态
Cannot export state from a module if it is reassigned. Either export a function returning the state value or only mutate the state value's properties无效状态
`%rune%(...)` can only be used as a variable declaration initializer, a class field declaration, or the first assignment to a class field at the top level of the constructor.存储无效作用域订阅
Cannot subscribe to stores that are not declared at the top level of the component存储无效订阅
Cannot reference store value inside `<script module>`存储无效订阅模块
Cannot reference store value outside a `.svelte` file使用$前缀来引用存储的值仅在.svelte文件内可行,其中 Svelte 可以在组件挂载时自动创建订阅,并在组件卸载时取消订阅。考虑迁移到 runes。
style_directive_invalid_modifier
`style:` directive can only use the `important` modifierstyle_duplicate
A component can have a single top-level `<style>` elementsvelte_body_非法属性
`<svelte:body>` does not support non-event attributes or spread attributessvelte_boundary_invalid_attribute
Valid attributes on `<svelte:boundary>` are `onerror` and `failed`svelte_boundary_invalid_attribute_value
Attribute value must be a non-string expressionsvelte 组件无效 this
Invalid component definition — must be an `{expression}`svelte 组件缺失此
`<svelte:component>` must have a 'this' attributesvelte_element_missing_this
`<svelte:element>` must have a 'this' attribute with a valuesvelte_fragment_invalid_attribute
`<svelte:fragment>` can only have a slot attribute and (optionally) a let: directivesvelte_fragment_invalid_placement
`<svelte:fragment>` must be the direct child of a componentsvelte_head_非法属性
`<svelte:head>` cannot have attributes nor directivessvelte_meta_duplicate
A component can only have one `<%name%>` elementsvelte_meta_invalid_content
<%name%> cannot have childrensvelte_meta_invalid_placement
`<%name%>` tags cannot be inside elements or blockssvelte_meta_invalid_tag
Valid `<svelte:...>` tag names are %list%svelte_options_deprecated_tag
"tag" option is deprecated — use "customElement" insteadsvelte_options_invalid_attribute
`<svelte:options>` can only receive static attributessvelte_options_invalid_attribute_value
Value must be %list%, if specifiedsvelte_options_invalid_customelement
"customElement" must be a string literal defining a valid custom element name or an object of the form { tag?: string; shadow?: "open" | "none"; props?: { [key: string]: { attribute?: string; reflect?: boolean; type: .. } } }svelte_options_invalid_customelement_props
"props" must be a statically analyzable object literal of the form "{ [key: string]: { attribute?: string; reflect?: boolean; type?: "String" | "Boolean" | "Number" | "Array" | "Object" }"svelte_options_invalid_customelement_shadow
"shadow" must be either "open" or "none"svelte_options_invalid_tagname
Tag name must be lowercase and hyphenated查看https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name获取有关有效标签名称的更多信息
svelte_options_reserved_tagname
标签名已保留
查看https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name获取有关有效标签名称的更多信息
svelte_options_未知属性
`<svelte:options>` unknown attribute '%name%'svelte_self_invalid_placement
`<svelte:self>` components can only exist inside `{#if}` blocks, `{#each}` blocks, `{#snippet}` blocks or slots passed to componentstag_invalid_name
Expected a valid element or component name. Components must have a valid variable name or dot notation expression标签无效位置
{@%name% ...} tag cannot be %location%文本区域无效内容
A `<textarea>` can have either a value attribute or (equivalently) child content, but not both标题_非法属性
`<title>` cannot have attributes nor directives标题无效内容
`<title>` can only contain text and {tags}过渡冲突
Cannot use `%type%:` alongside existing `%existing%:` directive过渡重复
Cannot use multiple `%type%:` directives on a single elementtypescript_invalid_feature
TypeScript language features like %feature% are not natively supported, and their use is generally discouraged. Outside of `<script>` tags, these features are not supported. For use within `<script>` tags, you will need to use a preprocessor to convert it to JavaScript before it gets passed to the Svelte compiler. If you are using `vitePreprocess`, make sure to specifically enable preprocessing script tags (`vitePreprocess({ script: true })`)意外 EOF
输入未预期结束
意外保留字
'%word%' is a reserved word in JavaScript and cannot be used here未终止的字符串常量
未终止的字符串常量
无效的空元素内容
Void elements cannot have children or closing tagsEdit this page on GitHub llms.txt