Skip to content

Commit fbb805c

Browse files
committed
docs: use setup script in cookbook
1 parent 4bf1c55 commit fbb805c

File tree

2 files changed

+14
-70
lines changed

2 files changed

+14
-70
lines changed

docs/advanced/cookbook/markdown-and-vue-sfc.md

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Markdown and Vue SFC
22

3-
Each Markdown file is first compiled into HTML, and then converted to a Vue SFC. In other words, you can take Markdown as Vue SFC:
3+
Each Markdown file is first compiled into HTML, and then converted to a Vue SFC. In other words, you can write a Markdown file like a Vue SFC:
44

55
- Blocks `<script>` and `<style>` are treated as Vue SFC blocks as they are. In other words, they are hoisted from the `<template>` block to the top-level of SFC.
66
- Everything outside `<script>` and `<style>` will be compiled into HTML, and be treated as Vue SFC `<template>` block.
@@ -24,7 +24,7 @@ _Current count is: {{ count }}_
2424
2525
<button @click="count++">Click Me!</button>
2626
27-
<script>
27+
<script setup>
2828
import { h, ref } from 'vue'
2929
3030
const RedDiv = (_, ctx) => h(
@@ -34,22 +34,8 @@ const RedDiv = (_, ctx) => h(
3434
},
3535
ctx.slots.default()
3636
)
37-
38-
export default {
39-
components: {
40-
RedDiv,
41-
},
42-
43-
setup() {
44-
const msg = 'Vue in Markdown'
45-
const count = ref(0)
46-
47-
return {
48-
msg,
49-
count,
50-
}
51-
}
52-
}
37+
const msg = 'Vue in Markdown'
38+
const count = ref(0)
5339
</script>
5440
5541
<style>
@@ -71,7 +57,7 @@ _Current count is: {{ count }}_
7157

7258
<button @click="count++">Click Me!</button>
7359

74-
<script>
60+
<script setup>
7561
import { h, ref } from 'vue'
7662

7763
const RedDiv = (_, ctx) => h(
@@ -81,22 +67,8 @@ const RedDiv = (_, ctx) => h(
8167
},
8268
ctx.slots.default()
8369
)
84-
85-
export default {
86-
components: {
87-
RedDiv,
88-
},
89-
90-
setup() {
91-
const msg = 'Vue in Markdown'
92-
const count = ref(0)
93-
94-
return {
95-
msg,
96-
count,
97-
}
98-
}
99-
}
70+
const msg = 'Vue in Markdown'
71+
const count = ref(0)
10072
</script>
10173

10274
<style>

docs/zh/advanced/cookbook/markdown-and-vue-sfc.md

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Markdown 与 Vue SFC
22

3-
每一个 Markdown 文件,首先都会编译为 HTML ,然后转换为一个 Vue 单文件组件 (SFC) 。换句话说,你可以把 Markdown 作为 Vue SFC 来看待
3+
每一个 Markdown 文件,首先都会编译为 HTML ,然后转换为一个 Vue 单文件组件 (SFC) 。换句话说,你可以像写 Vue SFC 一样来写 Markdown 文件
44

55
- `<script>``<style>` 标签会直接被当作 Vue SFC 中的标签。换句话说,它们是从 `<template>` 标签中提升到了 SFC 的顶层。
66
- 所有 `<script>``<style>` 标签的以外的内容,会先被编译为 HTML ,然后被当作 Vue SFC 的 `<template>` 标签。
@@ -24,7 +24,7 @@ _当前计数为: {{ count }}_
2424
2525
<button @click="count++">点我!</button>
2626
27-
<script>
27+
<script setup>
2828
import { h, ref } from 'vue'
2929
3030
const RedDiv = (_, ctx) => h(
@@ -34,22 +34,8 @@ const RedDiv = (_, ctx) => h(
3434
},
3535
ctx.slots.default()
3636
)
37-
38-
export default {
39-
components: {
40-
RedDiv,
41-
},
42-
43-
setup() {
44-
const msg = 'Markdown 中的 Vue'
45-
const count = ref(0)
46-
47-
return {
48-
msg,
49-
count,
50-
}
51-
}
52-
}
37+
const msg = 'Markdown 中的 Vue'
38+
const count = ref(0)
5339
</script>
5440
5541
<style>
@@ -71,7 +57,7 @@ _当前计数为: {{ count }}_
7157

7258
<button @click="count++">点我!</button>
7359

74-
<script>
60+
<script setup>
7561
import { h, ref } from 'vue'
7662

7763
const RedDiv = (_, ctx) => h(
@@ -81,22 +67,8 @@ const RedDiv = (_, ctx) => h(
8167
},
8268
ctx.slots.default()
8369
)
84-
85-
export default {
86-
components: {
87-
RedDiv,
88-
},
89-
90-
setup() {
91-
const msg = 'Markdown 中的 Vue'
92-
const count = ref(0)
93-
94-
return {
95-
msg,
96-
count,
97-
}
98-
}
99-
}
70+
const msg = 'Markdown 中的 Vue'
71+
const count = ref(0)
10072
</script>
10173

10274
<style>

0 commit comments

Comments
 (0)