Compiler Intrinsics
Compiler intrinsics are reserved identifiers that do not need to be declared inside component files and can be recognized and handled directly by the compiler. They are mainly used to access component attributes, reference attributes, and slot state, as well as to call built-in methods provided by the compiler.
props
props is used to read normal attributes and event attributes passed in from outside the component. Through it, a component can access data and event handlers passed by its parent, enabling communication and data flow between components.
See: Attributes
refs
refs is used to access reference attributes inside a component and perform writable updates. Through it, a component can obtain reference data passed in by its parent and modify that data directly to implement two-way binding or other interaction patterns.
See: Attributes, Reference Attributes
slots
slots is used to determine whether slot content has been passed into a component. Through it, a component can adjust its rendering logic based on whether the parent provides slot content.
See: Slots
reactive
reactive is a built-in method used to explicitly mark an identifier as having deep reactivity. How the compiler handles that identifier depends on how it is declared: when declared with let or var, both the identifier itself and all of its nested properties are inferred as reactive; when declared with const, the identifier itself cannot be reassigned, so only its properties are recursively inferred as reactive.
See: Reactivity Declaration, Reactive Depth, Reactivity Inference Rules
shallow
shallow is a built-in method used to explicitly mark an identifier as having shallow reactivity. How the compiler handles that identifier depends on how it is declared: when declared with let or var, only the identifier itself is inferred as reactive and its properties do not participate in reactive inference; when declared with const, only its first-level properties are inferred as reactive, and deeper properties are not.
See: Reactivity Declaration, Reactive Depth, Reactivity Inference Rules
raw
raw is a built-in method used to explicitly mark an identifier as a static value. An identifier marked with raw will not be given reactive behavior by the compiler, so modifying it will not trigger page updates.
See: Reactivity Declaration, Reactivity Inference Rules
alias
alias is a built-in method used to create an alias for an identifier. Through alias, developers can simplify complex access or write operations into more direct expressions while preserving reactivity.
See: Reactive Aliases, Destructure Built-in Objects
derived
derived is a built-in method used to create derived reactive state. Through derived, developers can define new reactive state based on existing reactive state. These derived values automatically track dependencies and update when those dependencies change.
derivedExp
derivedExp is a built-in method used to create a shorthand declaration for derived reactive state. Through derivedExp, developers can pass an expression directly to define derived state, and the compiler automatically converts it into a standard derived declaration.
watchExp
watchExp is a built-in method used to create a shorthand registration for a watcher. Through watchExp, developers can pass an expression directly to define watcher dependencies, and the compiler automatically converts it into a standard watch registration.
See: Watchers, Convenience Registration
preWatchExp
preWatchExp is a built-in method used to create a shorthand registration for a pre-watcher. Through preWatchExp, developers can pass an expression directly to define pre-watcher dependencies, and the compiler automatically converts it into a standard preWatch registration.
See: Watchers, Convenience Registration
postWatchExp
postWatchExp is a built-in method used to create a shorthand registration for a post-watcher. Through postWatchExp, developers can pass an expression directly to define post-watcher dependencies, and the compiler automatically converts it into a standard postWatch registration.
See: Watchers, Convenience Registration
syncWatchExp
syncWatchExp is a built-in method used to create a shorthand registration for a synchronous watcher. Through syncWatchExp, developers can pass an expression directly to define synchronous watcher dependencies, and the compiler automatically converts it into a standard syncWatch registration.
See: Watchers, Convenience Registration
watch
watch is a built-in method used to register a watcher for reactive state. When the observed value changes, the callback is invoked with the previous value and the current value. watch can be called directly without any import; the compiler binds it to the current component instance and cleans it up when the component is destroyed.
See: Watchers
preWatch
preWatch is a built-in method used to register a pre-watcher. A pre-watcher is triggered before the update scheduler runs, which is suitable for logic that needs to run after state changes but before template updates. preWatch can be called directly without any import; the compiler binds it to the current component instance and cleans it up when the component is destroyed.
See: Pre-Watchers
postWatch
postWatch is a built-in method used to register a post-watcher. A post-watcher is triggered after scheduled updates are complete, which is suitable for logic that needs to wait until the state is stable or the DOM has been updated. postWatch can be called directly without any import; the compiler binds it to the current component instance and cleans it up when the component is destroyed.
See: Post-Watchers
syncWatch
syncWatch is a built-in method used to register a synchronous watcher. Its callback is triggered immediately after a dependent reactive value changes, before the update scheduler runs. syncWatch can be called directly without any import; the compiler binds it to the current component instance and cleans it up when the component is destroyed.
See: Synchronous Watchers
effect
effect is a built-in method used to register a reactive side effect. Reactive values accessed while the callback runs are collected as dependencies automatically, and the callback reruns whenever any of them changes. effect can be called directly without any import; the compiler binds it to the current component instance and cleans it up when the component is destroyed.
See: Side Effects
preEffect
preEffect is a built-in method used to register a pre-effect. A pre-effect is triggered before the update scheduler runs, which is suitable for logic that needs to run after state changes but before template updates. preEffect can be called directly without any import; the compiler binds it to the current component instance and cleans it up when the component is destroyed.
See: Side Effects
postEffect
postEffect is a built-in method used to register a post-effect. A post-effect is triggered after scheduled updates are complete, which is suitable for logic that needs to wait until the state is stable or the DOM has been updated. postEffect can be called directly without any import; the compiler binds it to the current component instance and cleans it up when the component is destroyed.
See: Side Effects
syncEffect
syncEffect is a built-in method used to register a synchronous effect. Its callback is triggered immediately after a dependent reactive value changes, before the update scheduler runs. syncEffect can be called directly without any import; the compiler binds it to the current component instance and cleans it up when the component is destroyed.
See: Side Effects
defaults
defaults is a built-in method used to define default values for optional component attributes. It accepts an object as its argument: the props key specifies defaults for normal attributes and event attributes, and the refs key specifies defaults for reference attributes. When the parent component does not pass the corresponding attributes, those defaults are used.
defaults must be called once, as a standalone expression statement in the top-level scope of an embedded script block.
See: Specifying Default Values