You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Specifies a method to recognize custom elements defined outside of Vue (e.g., using the Web Components APIs). If component matches this condition, it won't need local or global registration and Vue won't throw a warning about an `Unknown custom element`.
94
-
95
-
> Note that all native HTML and SVG tags don't need to be matched in this function - Vue parser performs this check automatically
96
-
97
-
::: tip Important
98
-
This config option is only respected when using the runtime compiler. If you are using the runtime-only build, `isCustomElement` must be passed to `@vue/compiler-dom` in the build setup instead - for example, via the [`compilerOptions` option in vue-loader](https://vue-loader.vuejs.org/options.html#compileroptions).
The merge strategy receives the value of that option defined on the parent and child instances as the first and second arguments, respectively. The context application instance is passed as the third argument.
108
+
The merge strategy receives the value of that option defined on the parent and child instances as the first and second arguments, respectively.
@@ -139,3 +118,91 @@ The merge strategy receives the value of that option defined on the parent and c
139
118
-**Usage**:
140
119
141
120
Set this to `true` to enable component init, compile, render and patch performance tracing in the browser devtool performance/timeline panel. Only works in development mode and in browsers that support the [performance.mark](https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark) API.
121
+
122
+
## compilerOptions <Badgetext="3.1+" />
123
+
124
+
-**Type:**`Object`
125
+
126
+
Configure runtime compiler options. Values set on this object will be passed to the in-browser template compiler and affect every component in the configured app. Note you can also override these options on a per-component basis using the [`compilerOptions` option](/api/options-misc.html#compileroptions).
127
+
128
+
::: tip Important
129
+
This config option is only respected when using the full build (i.e. the standalone `vue.js` that can compile templates in the browser). If you are using the runtime-only build with a build setup, compiler options must be passed to `@vue/compiler-dom` via build tool configurations instead.
130
+
131
+
- For `vue-loader`: [pass via the `compilerOptions` loader option](https://vue-loader.vuejs.org/options.html#compileroptions). Also see [how to configure it in `vue-cli`](https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader).
132
+
133
+
- For `vite`: [pass via `@vitejs/plugin-vue` options](https://github.com/vitejs/vite/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-dom).
134
+
:::
135
+
136
+
### compilerOptions.isCustomElement
137
+
138
+
-**Type:**`(tag: string) => boolean`
139
+
140
+
-**Default:**`undefined`
141
+
142
+
-**Usage:**
143
+
144
+
```js
145
+
// any element starting with 'ion-' will be recognized as a custom one
Specifies a method to recognize custom elements defined outside of Vue (e.g., using the Web Components APIs). If component matches this condition, it won't need local or global registration and Vue won't throw a warning about an `Unknown custom element`.
150
+
151
+
> Note that all native HTML and SVG tags don't need to be matched in this function - Vue parser performs this check automatically.
152
+
153
+
### compilerOptions.whitespace
154
+
155
+
-**Type:**`'condense' | 'preserve'`
156
+
157
+
-**Default:**`'condense'`
158
+
159
+
-**Usage:**
160
+
161
+
```js
162
+
app.config.compilerOptions.whitespace='preserve'
163
+
```
164
+
165
+
By default, Vue removes/condenses whitespaces between template elements to produce more efficient compiled output:
166
+
167
+
1. Leading / ending whitespaces inside an element are condensed into a single space
168
+
2. Whitespaces between elements that contain newlines are removed
169
+
3. Consecutive whitespaces in text nodes are condensed into a single space
170
+
171
+
Setting the value to `'preserve'` will disable (2) and (3).
Sets the delimiters used for text interpolation within the template.
187
+
188
+
Typically this is used to avoid conflicting with server-side frameworks that also use mustache syntax.
189
+
190
+
### compilerOptions.comments
191
+
192
+
-**Type:**`boolean`
193
+
194
+
-**Default:**`false`
195
+
196
+
-**Usage:**
197
+
198
+
```js
199
+
app.config.compilerOptions.comments=true
200
+
```
201
+
202
+
By default, Vue will remove HTML comments inside templates in production. Setting this option to `true` will force Vue to preserve comments even in production. Comments are always preserved during development.
203
+
204
+
This option is typically used when Vue is used with other libraries that rely on HTML comments.
Copy file name to clipboardExpand all lines: src/api/composition-api.md
+66-43Lines changed: 66 additions & 43 deletions
Original file line number
Diff line number
Diff line change
@@ -4,32 +4,51 @@
4
4
5
5
## `setup`
6
6
7
-
A component option that is executed **before** the component is created, once the `props` are resolved, and serves as the entry point for composition API's
7
+
A component option that is executed **before** the component is created, once the `props` are resolved. It serves as the entry point for composition APIs.
8
8
9
9
-**Arguments:**
10
10
11
11
-`{Data} props`
12
12
-`{SetupContext} context`
13
13
14
+
Similar to `this.$props` when using Options API, the `props` object will only contain explicitly declared props. Also, all declared prop keys will be present on the `props` object, regardless of whether it was passed by the parent component or not. Absent optional props will have a value of `undefined`.
15
+
16
+
If you need to check the absence of an optional prop, you can give it a Symbol as its default value:
17
+
18
+
```js
19
+
constisAbsent=Symbol()
20
+
21
+
exportdefault {
22
+
props: {
23
+
foo: { default: isAbsent }
24
+
},
25
+
setup(props) {
26
+
if (props.foo=== isAbsent) {
27
+
// foo was not provided.
28
+
}
29
+
}
30
+
}
31
+
```
32
+
14
33
-**Typing**:
15
34
16
-
```ts
17
-
interfaceData {
18
-
[key:string]:unknown
19
-
}
35
+
```ts
36
+
interfaceData {
37
+
[key:string]:unknown
38
+
}
20
39
21
-
interfaceSetupContext {
22
-
attrs:Data
23
-
slots:Slots
24
-
emit: (event:string, ...args:unknown[]) =>void
25
-
}
40
+
interfaceSetupContext {
41
+
attrs:Data
42
+
slots:Slots
43
+
emit: (event:string, ...args:unknown[]) =>void
44
+
}
26
45
27
-
function setup(props:Data, context:SetupContext):Data
28
-
```
46
+
function setup(props:Data, context:SetupContext):Data
47
+
```
29
48
30
-
::: tip
31
-
Togettypeinference for the arguments passed to `setup()`, the use of [defineComponent](global-api.html#definecomponent) is needed.
32
-
:::
49
+
::: tip
50
+
Togettypeinference for the arguments passed to `setup()`, the use of [defineComponent](global-api.html#definecomponent) is needed.
51
+
:::
33
52
34
53
-**Example**
35
54
@@ -129,48 +148,52 @@ The component instance context is also set during the synchronous execution of l
129
148
130
149
-**Typing**:
131
150
132
-
```ts
133
-
interface InjectionKey<T> extends Symbol {}
134
-
135
-
function provide<T>(key: InjectionKey<T> | string, value: T): void
136
-
137
-
// without default value
138
-
function inject<T>(key: InjectionKey<T> | string): T | undefined
139
-
// with default value
140
-
function inject<T>(key: InjectionKey<T> | string, defaultValue: T): T
141
-
// with factory
142
-
function inject<T>(
143
-
key: InjectionKey<T> | string,
144
-
defaultValue: () => T,
145
-
treatDefaultAsFactory: true
146
-
): T
147
-
```
151
+
```ts
152
+
interface InjectionKey<T> extends Symbol {}
153
+
154
+
function provide<T>(key: InjectionKey<T> | string, value: T): void
155
+
156
+
// without default value
157
+
function inject<T>(key: InjectionKey<T> | string): T | undefined
158
+
// with default value
159
+
function inject<T>(key: InjectionKey<T> | string, defaultValue: T): T
> Note: this section only affects cases where Vue templates are directly written in the page's HTML.
460
-
461
-
-**Expects:** string literal
462
-
463
-
-**Limited to:** native HTML elements
464
-
465
-
-**Usage:** When using in-DOM templates, the template is subject to native HTML parsing rules. Some HTML elements, such as `<ul>`, `<ol>`, `<table>` and `<select>` have restrictions on what elements can appear inside them, and some elements such as `<li>`, `<tr>`, and `<option>` can only appear inside certain other elements. As a workaround, we can use `v-is` directive on these elements:
466
-
467
-
```html
468
-
<table>
469
-
<trv-is="'blog-post-row'"></tr>
470
-
</table>
471
-
```
472
-
473
-
:::warning
474
-
`v-is` functions like a dynamic 2.x `:is` binding - so to render a component by its registered name, its value should be a JavaScript string literal:
475
-
476
-
```html
477
-
<!-- Incorrect, nothing will be rendered -->
478
-
<trv-is="blog-post-row"></tr>
479
-
480
-
<!-- Correct -->
481
-
<trv-is="'blog-post-row'"></tr>
482
-
```
483
-
484
-
:::
459
+
Deprecated in 3.1.0. Use [`is` attribute with `vue:` prefix](/api/special-attributes.html#is) instead.
Copy file name to clipboardExpand all lines: src/api/options-misc.md
+28-23Lines changed: 28 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -10,29 +10,6 @@
10
10
11
11
Another benefit of specifying a `name` option is debugging. Named components result in more helpful warning messages. Also, when inspecting an app in the [vue-devtools](https://github.com/vuejs/vue-devtools), unnamed components will show up as `<AnonymousComponent>`, which isn't very informative. By providing the `name` option, you will get a much more informative component tree.
0 commit comments