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
Copy file name to clipboardExpand all lines: src/guide/scaling-up/sfc.md
+4-24Lines changed: 4 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -35,8 +35,8 @@ export default {
35
35
36
36
```vue
37
37
<script setup>
38
-
import { ref } from 'vue';
39
-
const greeting = ref('Hello World!');
38
+
import { ref } from 'vue'
39
+
const greeting = ref('Hello World!')
40
40
}
41
41
</script>
42
42
@@ -81,36 +81,16 @@ That said, we do realize there are scenarios where SFCs can feel like overkill.
81
81
82
82
Vue SFC is a framework-specific file format and must be pre-compiled by [@vue/compiler-sfc](https://github.com/vuejs/core/tree/main/packages/compiler-sfc) into standard JavaScript and CSS. A compiled SFC is a standard JavaScript (ES) module - which means with proper build setup you can import an SFC like a module:
83
83
84
-
<divclass="options-api">
85
-
86
-
```vue
87
-
88
-
<script>
89
-
import MyComponent from './MyComponent.vue';
84
+
```js
85
+
importMyComponentfrom'./MyComponent.vue'
90
86
91
87
exportdefault {
92
88
components: {
93
89
MyComponent
94
90
}
95
91
}
96
-
</script>
97
92
```
98
93
99
-
</div>
100
-
101
-
<divclass="composition-api">
102
-
103
-
```vue
104
-
<script setup>
105
-
import MyComponent from './MyComponent.vue';
106
-
107
-
</script>
108
-
```
109
-
110
-
With `<script setup>`, imported components are automatically made available to the template.
111
-
112
-
</div>
113
-
114
94
`<style>` tags inside SFCs are typically injected as native `<style>` tags during development to support hot updates. For production they can be extracted and merged into a single CSS file.
115
95
116
96
You can play with SFCs and explore how they are compiled in the [Vue SFC Playground](https://sfc.vuejs.org/).
0 commit comments