Skip to content

Commit c417157

Browse files
committed
chore: mark some more code to twoslash
1 parent 7b9fff2 commit c417157

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

.vitepress/config.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,6 @@ export default defineConfigWithTheme<ThemeConfig>({
623623
]
624624
],
625625

626-
627-
628626
themeConfig: {
629627
nav,
630628
sidebar,
@@ -726,6 +724,7 @@ export default defineConfigWithTheme<ThemeConfig>({
726724

727725
vite: {
728726
define: {
727+
// Turn this back off after floating-vue migrated to Composition API
729728
__VUE_OPTIONS_API__: true
730729
},
731730
optimizeDeps: {

src/guide/essentials/application.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Every Vue application starts by creating a new **application instance** with the [`createApp`](/api/application#createapp) function:
66

7-
```js
7+
```js twoslash
88
import { createApp } from 'vue'
99

1010
const app = createApp({
@@ -18,7 +18,7 @@ The object we are passing into `createApp` is in fact a component. Every app req
1818

1919
If you are using Single-File Components, we typically import the root component from another file:
2020

21-
```js
21+
```js twoslash
2222
import { createApp } from 'vue'
2323
// import the root component App from a single-file component.
2424
import App from './App.vue'
@@ -67,7 +67,7 @@ The template for the root component is usually part of the component itself, but
6767
</div>
6868
```
6969

70-
```js
70+
```js twoslash
7171
import { createApp } from 'vue'
7272

7373
const app = createApp({

src/guide/essentials/reactivity-fundamentals.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ When you access `this.someObject` after assigning it, the value is a reactive pr
7373

7474
In Composition API, the recommended way to declare reactive state is using the [`ref()`](/api/reactivity-core#ref) function:
7575

76-
```js
76+
```js twoslash
7777
import { ref } from 'vue'
7878

7979
const count = ref(0)
8080
```
8181

8282
`ref()` takes the argument and returns it wrapped within a ref object with a `.value` property:
8383

84-
```js
84+
```js twoslash
8585
const count = ref(0)
8686

8787
console.log(count) // { value: 0 }
@@ -95,7 +95,7 @@ console.log(count.value) // 1
9595
9696
To access refs in a component's template, declare and return them from a component's `setup()` function:
9797

98-
```js{5,9-11}
98+
```js{5,9-11} twoslash
9999
import { ref } from 'vue'
100100
101101
export default {
@@ -127,7 +127,7 @@ You can also mutate a ref directly in event handlers:
127127

128128
For more complex logic, we can declare functions that mutate refs in the same scope and expose them as methods alongside the state:
129129

130-
```js{7-10,15}
130+
```js{7-10,15} twoslash
131131
import { ref } from 'vue'
132132
133133
export default {
@@ -150,7 +150,7 @@ export default {
150150

151151
Exposed methods can then be used as event handlers:
152152

153-
```vue-html{1}
153+
```vue{1}
154154
<button @click="increment">
155155
{{ count }}
156156
</button>
@@ -162,7 +162,7 @@ Here's the example live on [Codepen](https://codepen.io/vuejs-examples/pen/WNYba
162162

163163
Manually exposing state and methods via `setup()` can be verbose. Luckily, it can be avoided when using [Single-File Components (SFCs)](/guide/scaling-up/sfc). We can simplify the usage with `<script setup>`:
164164

165-
```vue{1}
165+
```vue{1} twoslash
166166
<script setup>
167167
import { ref } from 'vue'
168168
@@ -305,7 +305,7 @@ Refs can hold any value type, including deeply nested objects, arrays, or JavaSc
305305

306306
A ref will make its value deeply reactive. This means you can expect changes to be detected even when you mutate nested objects or arrays:
307307

308-
```js
308+
```js twoslash
309309
import { ref } from 'vue'
310310

311311
const obj = ref({

src/guide/introduction.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ With Composition API, we define a component's logic using imported API functions
211211

212212
Here is the same component, with the exact same template, but using Composition API and `<script setup>` instead:
213213

214-
```vue
214+
```vue twoslash
215215
<script setup>
216216
import { ref, onMounted } from 'vue'
217217

0 commit comments

Comments
 (0)