Skip to content

Commit c81aa79

Browse files
authored
docs: update crash-course to script setup
Related to #2642
1 parent 44f856d commit c81aa79

File tree

3 files changed

+81
-123
lines changed

3 files changed

+81
-123
lines changed

docs/fr/guide/essentials/a-crash-course.md

Lines changed: 29 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,16 @@ Commençons par un simple composant TodoApp avec une seule tâche :
1616
<div></div>
1717
</template>
1818
19-
<script>
20-
export default {
21-
name: 'TodoApp',
22-
23-
data() {
24-
return {
25-
todos: [
26-
{
27-
id: 1,
28-
text: 'Apprendre Vue.js 3',
29-
completed: false,
30-
},
31-
],
32-
};
33-
},
34-
};
19+
<script setup>
20+
import { ref } from 'vue'
21+
22+
const todos = ref([
23+
{
24+
id: 1,
25+
text: 'Apprendre Vue.js 3',
26+
completed: false
27+
}
28+
])
3529
</script>
3630
```
3731

@@ -116,33 +110,25 @@ Si nous exécutons ce test, il échouera. Modifions `TodoApp.vue` pour avoir les
116110
</div>
117111
</template>
118112
119-
<script>
120-
export default {
121-
name: 'TodoApp',
122-
123-
data() {
124-
return {
125-
newTodo: '',
126-
todos: [
127-
{
128-
id: 1,
129-
text: 'Apprendre Vue.js 3',
130-
completed: false,
131-
},
132-
],
133-
};
134-
},
135-
136-
methods: {
137-
createTodo() {
138-
this.todos.push({
139-
id: 2,
140-
text: this.newTodo,
141-
completed: false,
142-
});
143-
},
144-
},
145-
};
113+
<script setup>
114+
import { ref } from 'vue'
115+
116+
const newTodo = ref(''),
117+
const todos = ref([
118+
{
119+
id: 1,
120+
text: 'Apprendre Vue.js 3',
121+
completed: false
122+
}
123+
])
124+
125+
const createTodo = () => {
126+
todos.value.push({
127+
id: 2,
128+
text: newTodo.value,
129+
completed: false
130+
})
131+
}
146132
</script>
147133
```
148134

docs/guide/essentials/a-crash-course.md

Lines changed: 26 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,16 @@ We will start off with a simple `TodoApp` component with a single todo:
1717
<div></div>
1818
</template>
1919
20-
<script>
21-
export default {
22-
name: 'TodoApp',
23-
24-
data() {
25-
return {
26-
todos: [
27-
{
28-
id: 1,
29-
text: 'Learn Vue.js 3',
30-
completed: false
31-
}
32-
]
33-
}
20+
<script setup>
21+
import { ref } from 'vue'
22+
23+
const todos = ref([
24+
{
25+
id: 1,
26+
text: 'Learn Vue.js 3',
27+
completed: false
3428
}
35-
}
29+
])
3630
</script>
3731
```
3832

@@ -117,32 +111,24 @@ If we run this test, it will obviously fail. Let's update `TodoApp.vue` to have
117111
</div>
118112
</template>
119113
120-
<script>
121-
export default {
122-
name: 'TodoApp',
123-
124-
data() {
125-
return {
126-
newTodo: '',
127-
todos: [
128-
{
129-
id: 1,
130-
text: 'Learn Vue.js 3',
131-
completed: false
132-
}
133-
]
134-
}
135-
},
136-
137-
methods: {
138-
createTodo() {
139-
this.todos.push({
140-
id: 2,
141-
text: this.newTodo,
142-
completed: false
143-
})
144-
}
114+
<script setup>
115+
import { ref } from 'vue'
116+
117+
const newTodo = ref(''),
118+
const todos = ref([
119+
{
120+
id: 1,
121+
text: 'Learn Vue.js 3',
122+
completed: false
145123
}
124+
])
125+
126+
const createTodo = () => {
127+
todos.value.push({
128+
id: 2,
129+
text: newTodo.value,
130+
completed: false
131+
})
146132
}
147133
</script>
148134
```

docs/zh/guide/essentials/a-crash-course.md

Lines changed: 26 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,16 @@
1616
<div></div>
1717
</template>
1818
19-
<script>
20-
export default {
21-
name: 'TodoApp',
22-
23-
data() {
24-
return {
25-
todos: [
26-
{
27-
id: 1,
28-
text: 'Learn Vue.js 3',
29-
completed: false
30-
}
31-
]
32-
}
19+
<script setup>
20+
import { ref } from 'vue'
21+
22+
const todos = ref([
23+
{
24+
id: 1,
25+
text: 'Learn Vue.js 3',
26+
completed: false
3327
}
34-
}
28+
])
3529
</script>
3630
```
3731

@@ -116,32 +110,24 @@ test('creates a todo', () => {
116110
</div>
117111
</template>
118112
119-
<script>
120-
export default {
121-
name: 'TodoApp',
122-
123-
data() {
124-
return {
125-
newTodo: '',
126-
todos: [
127-
{
128-
id: 1,
129-
text: 'Learn Vue.js 3',
130-
completed: false
131-
}
132-
]
133-
}
134-
},
135-
136-
methods: {
137-
createTodo() {
138-
this.todos.push({
139-
id: 2,
140-
text: this.newTodo,
141-
completed: false
142-
})
143-
}
113+
<script setup>
114+
import { ref } from 'vue'
115+
116+
const newTodo = ref(''),
117+
const todos = ref([
118+
{
119+
id: 1,
120+
text: 'Learn Vue.js 3',
121+
completed: false
144122
}
123+
])
124+
125+
const createTodo = () => {
126+
todos.value.push({
127+
id: 2,
128+
text: newTodo.value,
129+
completed: false
130+
})
145131
}
146132
</script>
147133
```

0 commit comments

Comments
 (0)