Skip to content

Commit 1fbb571

Browse files
committed
refine intro
1 parent 84bb84e commit 1fbb571

File tree

2 files changed

+43
-26
lines changed

2 files changed

+43
-26
lines changed

src/ecosystem/official-projects.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/guide/introduction.md

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,27 @@ const count = ref(0)
4646
<button @click="count = 0">Reset</button>
4747
</p>
4848

49+
The above example demonstrates the two core features of Vue:
50+
51+
- **Declarative Rendering**: Vue extends standard HTML with templating syntax that allows us to declaratively describe HTML output based on JavaScript state.
52+
53+
- **Reactivity**: Vue automatically tracks JavaScript state changes and efficiently updates the DOM when changes happen.
54+
4955
You may already have questions - don't worry! We will cover every little detail in the rest of the documentation. For now, please read along so you can have a high-level understanding of what Vue is all about.
5056

5157
## Ways of Using Vue
5258

53-
Vue is a framework. This means that as a whole, it provides a comprehensive feature set that covers most of the common needs in frontend web development. But the web is extremely diverse - the things we build on the web may vary drastically in form and scale. With that in mind, Vue is designed to be incrementally adoptable. Depending on your use case, Vue can be leveraged in different ways:
59+
Vue is a framework. As a whole, it covers most of the common features needed in frontend development. But the web is extremely diverse - the things we build on the web may vary drastically in form and scale. With that in mind, Vue is designed to be flexible and incrementally adoptable. Depending on your use case, Vue can be used in different ways:
5460

55-
### Progressive Enhancement
61+
### Standalone Script
5662

57-
Vue can be used as a more declarative JQuery replacement to "sprinkle" reactivity on to static or backend-rendered HTML pages. The core can be used as a standalone script by simply loading it from a CDN - no build step required!
63+
Vue can be used as a standalone script file - no build step required! If you have a backend framework already rendering most of the HTML, or your frontend logic isn't complex enough to demand a build step, this is the easiest way to integrate Vue into your stack. You can think of Vue as a more declarative replacement of jQuery in such cases.
5864

59-
Vue also provides an alternative distribution called [petite-vue](https://github.com/vuejs/petite-vue) that is specifically optimized for progressive enhancement. It has a smaller feature set, but is extremely lightweight and uses an implementation that is more efficient in no-build-setup scenarios.
65+
Vue also provides an alternative distribution called [petite-vue](https://github.com/vuejs/petite-vue) that is specifically optimized for progressively enhancing existing HTML. It has a smaller feature set, but is extremely lightweight and uses an implementation that is more efficient in no-build-setup scenarios.
6066

6167
### Single-Page Application (SPA)
6268

63-
You can build rich, large scale applications where Vue not only controls the entire page, but also handles data updates and navigations without having to reload the page. This type of applications are typically referred to as Single-Page Applications (SPAs).
69+
Some applications require rich interactivity and non-trivial stateful logic on the frontend. The best way to build such applications is to use an architecture where Vue not only controls the entire page, but also handles data updates and navigations without having to reload the page. This type of applications are typically referred to as Single-Page Applications (SPAs).
6470

6571
Vue provides core libraries and [comprehensive tooling support](/guide/scaling-up/tooling) with amazing developer experience for building modern SPAs, including:
6672

@@ -71,19 +77,23 @@ Vue provides core libraries and [comprehensive tooling support](/guide/scaling-u
7177
- TypeScript integrations
7278
- Testing utilities
7379

74-
If you are a beginner and find these concepts intimidating, don't worry! The main guide only requires basic HTML and JavaScript knowledge, and you can follow along without being an expert at any of the above.
80+
:::tip
81+
If you are a beginner and find the concepts discussed here or below intimidating, don't worry! The main guide only requires basic HTML and JavaScript knowledge, and you can follow along without prior experience in any of these.
82+
:::
7583

7684
### Fullstack / SSR
7785

78-
Vue provides first-class APIs to render a Vue application into HTML on the server side so that the end user can see the content as soon as possible, without having to wait for the JavaScript to load and execute. Vue will then "hydrate" the application on the client side to make it interactive. This is called [Server-Side Rendering (SSR)](/guide/advanced/server-side-rendering) and is a necessary feature in cases where SEO and time-to-content are critical.
86+
Pure client-side SPAs are problematic when the app is sensitive to SEO and time-to-content. This is because the browser will receive a largely empty HTML page, and has to wait until the JavaScript is loaded before anything can be rendered.
87+
88+
Vue provides first-class APIs to render a Vue app into HTML on the server. This allows the server to send back already-rendered HTML, allowing end users to see the content immediately while the JavaScript is being downloaded. Vue will then "hydrate" the application on the client side to make it interactive. This is called [Server-Side Rendering (SSR)](/guide/advanced/server-side-rendering) and it greatly improves Core Web Vital metrics such as [Largest Contentful Paint (LCP)](https://web.dev/lcp/).
7989

8090
There are higher-level Vue-based frameworks built on top of this paradigm, such as [NuxtJS](https://nuxtjs.org/), which allow you to develop a fullstack application using Vue and JavaScript.
8191

8292
### JAMStack / SSG
8393

84-
Server-side rendering can be done ahead of time if the data is static. This means we can pre-render an entire application into HTML and serve them as static pages, greatly improving server performance and reducing deployment complexity. Vue can still hydrate such applications to provide rich interactivity on the client. This technique is commonly referred to as Static-Site Generation (SSG), also known as [JAMStack](https://jamstack.org/what-is-jamstack/).
94+
Server-side rendering can be done ahead of time if the required data is static. This means we can pre-render an entire application into HTML and serve them as static files. This improves site performance and makes deployment a lot simpler since we no longer need to dynamically render pages on each request. Vue can still hydrate such applications to provide rich interactivity on the client. This technique is commonly referred to as Static-Site Generation (SSG), also known as [JAMStack](https://jamstack.org/what-is-jamstack/).
8595

86-
The Vue team maintains a static-site generator called [VitePress](https://vitepress.vuejs.org/), which powers this very website! In addition, [NuxtJS](https://nuxtjs.org/) also supports SSG.
96+
The Vue team maintains a static-site generator called [VitePress](https://vitepress.vuejs.org/), which powers this website you reading right now! In addition, [NuxtJS](https://nuxtjs.org/) also supports SSG.
8797

8898
### Beyond the Web
8999

@@ -94,34 +104,40 @@ Although Vue is primarily designed for building web applications, it is by no me
94104
- Build desktop and mobile apps from the same codebase with [Quasar](https://quasar.dev/)
95105
- Use Vue's [Custom Renderer API](/api/custom-renderer) to build custom renderers targeting [WebGL](https://troisjs.github.io/) or even [the terminal](https://github.com/ycmjason/vuminal)!
96106

107+
### The Progressive Framework
108+
109+
The fundamental knowledge about how Vue works is shared across all the above use cases. Even if you are just a beginner now and are starting with the simplest steps, the knowledge gained will stay useful as you grow to tackle more ambitious goals in the future. If you are a veteran, you can pick the best way to leverage Vue based on the problems you are trying to solve, while retaining the same productivity. Vue is a progressive framework that can grow with you and adapt to your needs.
110+
97111
## Single-File Components
98112

99-
In most build-tool-enabled Vue projects, we author Vue components using an HTML-like file format called **Single-File Component** (also known as `*.vue` files, abbreviated as **SFC**). A Vue SFC, as the name suggests, encapsulates the component's logic (JavaScript), template (HTML), and styles (CSS) in a single file:
113+
In most build-tool-enabled Vue projects, we author Vue components using an HTML-like file format called **Single-File Component** (also known as `*.vue` files, abbreviated as **SFC**). A Vue SFC, as the name suggests, encapsulates the component's logic (JavaScript), template (HTML), and styles (CSS) in a single file. Here's the previous counter example, written in SFC format:
100114

101115
```vue
102116
<script>
103117
export default {
104118
data() {
105119
return {
106-
greeting: 'Hello World!'
120+
count: 0
107121
}
108122
}
109123
}
110124
</script>
111125
112126
<template>
113-
<p class="greeting">{{ greeting }}</p>
127+
<button @click="count++">
128+
Clicked {{ count }} time{{ count === 1 ? '' : 's' }}.
129+
</button>
130+
<button @click="count = 0">Reset</button>
114131
</template>
115132
116-
<style>
117-
.greeting {
118-
color: red;
133+
<style scoped>
134+
button {
119135
font-weight: bold;
120136
}
121137
</style>
122138
```
123139

124-
SFC is a defining feature of Vue, and is the recommended way to author Vue components **if** your use case warrants a build setup. You can learn more about the [how and why of SFC](/guide/scaling-up/sfc) in its dedicated section - but for now, just know that Vue provides tools that can help you scaffold SFC-ready projects in minutes.
140+
SFC is a defining feature of Vue, and is the recommended way to author Vue components **if** your use case warrants a build setup. You can learn more about the [how and why of SFC](/guide/scaling-up/sfc) in its dedicated section - but for now, just know that Vue will handle all the build tools setup for you.
125141

126142
## API Styles
127143

@@ -134,21 +150,25 @@ With Options API, we define a component's logic using an object of options such
134150
```vue
135151
<script>
136152
export default {
137-
// reactive state
153+
// Properties returned from data() becomes reactive state
154+
// and will be exposed on `this`.
138155
data() {
139156
return {
140157
count: 0
141158
}
142159
},
143160
144-
// functions that mutate state and trigger updates
161+
// Methods are functions that mutate state and trigger updates.
162+
// They can be bound as event listeners in templates.
145163
methods: {
146164
increment() {
147165
this.count++
148166
}
149167
},
150168
151-
// lifecycle hooks
169+
// Lifecycle hooks are called at different stages
170+
// of a component's lifecycle.
171+
// This function will be called when the component is mounted.
152172
mounted() {
153173
console.log(`The initial count is ${this.count}.`)
154174
}
@@ -164,7 +184,9 @@ export default {
164184

165185
### Composition API
166186

167-
With Composition API, we define a component's logic using imported API functions. In SFCs, Composition API is typically used with [`<script setup>`](/api/sfc-script-setup), which exposes all imports and declared variables directly to the template. Here's the same component, with the exact same template, but using Composition API and `<script setup>` instead:
187+
With Composition API, we define a component's logic using imported API functions. In SFCs, Composition API is typically used with [`<script setup>`](/api/sfc-script-setup). Imports and top-level variables and functions declared in `<script setup>` are directly usable in the template.
188+
189+
Here is the same component, with the exact same template, but using Composition API and `<script setup>` instead:
168190

169191
```vue
170192
<script setup>
@@ -211,7 +233,7 @@ If you are new to Vue, here's our general recommendation:
211233

212234
- Go with Composition API + Single File Components if you plan to build full applications with Vue.
213235

214-
You don't have to commit to only one style during the learning phase. The rest of the documentation will provide code samples in both styles where applicable, and you can toggle between them at any time using the switches at the top of the left sidebar.
236+
You don't have to commit to only one style during the learning phase. The rest of the documentation will provide code samples in both styles where applicable, and you can toggle between them at any time using the API Preference switches at the top of the left sidebar.
215237

216238
## Still Got Questions?
217239

0 commit comments

Comments
 (0)