Skip to content

Commit f184e25

Browse files
author
ntepluhina
committed
fix: fixed forms and prettier
1 parent 3fefe1d commit f184e25

File tree

8 files changed

+151
-140
lines changed

8 files changed

+151
-140
lines changed

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true
4+
}

src/guide/class-and-style.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ When you use the `class` attribute on a custom component, those classes will be
130130
For example, if you declare this component:
131131

132132
```js
133-
const app = Vue.createApp();
133+
const app = Vue.createApp()
134134

135-
app.component("my-component", {
135+
app.component('my-component', {
136136
template: `<p class="foo bar">Hi!</p>`
137-
});
137+
})
138138
```
139139

140140
Then add some classes when using it:

src/guide/computed.md

+31-31
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ That's why for complex logic that includes reactive data, you should use a **com
2929
const vm = Vue.createApp({
3030
data() {
3131
return {
32-
message: "Hello"
33-
};
32+
message: 'Hello'
33+
}
3434
},
3535
computed: {
3636
// a computed getter
3737
reversedMessage() {
3838
// `this` points to the vm instance
3939
return this.message
40-
.split("")
40+
.split('')
4141
.reverse()
42-
.join("");
42+
.join('')
4343
}
4444
}
45-
}).mount("#example");
45+
}).mount('#example')
4646
```
4747

4848
Result:
@@ -52,9 +52,9 @@ Result:
5252
Here we have declared a computed property `reversedMessage`. The function we provided will be used as the getter function for the property `vm.reversedMessage`:
5353

5454
```js
55-
console.log(vm.reversedMessage); // => 'olleH'
56-
vm.message = "Goodbye";
57-
console.log(vm.reversedMessage); // => 'eybdooG'
55+
console.log(vm.reversedMessage) // => 'olleH'
56+
vm.message = 'Goodbye'
57+
console.log(vm.reversedMessage) // => 'eybdooG'
5858
```
5959

6060
You can open the sandbox(TODO) and play with the example vm yourself. The value of `vm.reversedMessage` is always dependent on the value of `vm.message`.
@@ -106,20 +106,20 @@ Vue does provide a more generic way to observe and react to data changes on a Vu
106106
const vm = Vue.createApp({
107107
data() {
108108
return {
109-
firstName: "Foo",
110-
lastName: "Bar",
111-
fullName: "Foo Bar"
112-
};
109+
firstName: 'Foo',
110+
lastName: 'Bar',
111+
fullName: 'Foo Bar'
112+
}
113113
},
114114
watch: {
115115
firstName(val) {
116-
this.fullName = val + " " + this.lastName;
116+
this.fullName = val + ' ' + this.lastName
117117
},
118118
lastName(val) {
119-
this.fullName = this.firstName + " " + val;
119+
this.fullName = this.firstName + ' ' + val
120120
}
121121
}
122-
}).mount("#demo");
122+
}).mount('#demo')
123123
```
124124

125125
The above code is imperative and repetitive. Compare it with a computed property version:
@@ -128,16 +128,16 @@ The above code is imperative and repetitive. Compare it with a computed property
128128
const vm = Vue.createApp({
129129
data() {
130130
return {
131-
firstName: "Foo",
132-
lastName: "Bar"
133-
};
131+
firstName: 'Foo',
132+
lastName: 'Bar'
133+
}
134134
},
135135
computed: {
136136
fullName() {
137-
return this.firstName + " " + this.lastName;
137+
return this.firstName + ' ' + this.lastName
138138
}
139139
}
140-
}).mount("#demo");
140+
}).mount('#demo')
141141
```
142142

143143
Much better, isn't it?
@@ -193,32 +193,32 @@ For example:
193193
const watchExampleVM = Vue.createApp({
194194
data() {
195195
return {
196-
question: "",
197-
answer: "Questions usually contain a question mark. ;-)"
198-
};
196+
question: '',
197+
answer: 'Questions usually contain a question mark. ;-)'
198+
}
199199
},
200200
watch: {
201201
// whenever question changes, this function will run
202202
question(newQuestion, oldQuestion) {
203-
if (newQuestion.indexOf("?") > -1) {
204-
this.getAnswer();
203+
if (newQuestion.indexOf('?') > -1) {
204+
this.getAnswer()
205205
}
206206
}
207207
},
208208
methods: {
209209
getAnswer() {
210-
this.answer = "Thinking...";
210+
this.answer = 'Thinking...'
211211
axios
212-
.get("https://yesno.wtf/api")
212+
.get('https://yesno.wtf/api')
213213
.then(response => {
214-
this.answer = _.capitalize(response.data.answer);
214+
this.answer = _.capitalize(response.data.answer)
215215
})
216216
.catch(error => {
217-
this.answer = "Error! Could not reach the API. " + error;
218-
});
217+
this.answer = 'Error! Could not reach the API. ' + error
218+
})
219219
}
220220
}
221-
}).mount("#watch-example");
221+
}).mount('#watch-example')
222222
</script>
223223
```
224224

src/guide/events.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ Vue.createApp({
2020
data() {
2121
return {
2222
counter: 1
23-
};
23+
}
2424
}
25-
}).mount("#example-1");
25+
}).mount('#example-1')
2626
```
2727

2828
Result:
@@ -46,20 +46,20 @@ For example:
4646
Vue.createApp({
4747
data() {
4848
return {
49-
name: "Vue.js"
50-
};
49+
name: 'Vue.js'
50+
}
5151
},
5252
methods: {
5353
greet(event) {
5454
// `this` inside methods points to the Vue instance
55-
alert("Hello " + this.name + "!");
55+
alert('Hello ' + this.name + '!')
5656
// `event` is the native DOM event
5757
if (event) {
58-
alert(event.target.tagName);
58+
alert(event.target.tagName)
5959
}
6060
}
6161
}
62-
}).mount("#example-2");
62+
}).mount('#example-2')
6363
```
6464

6565
Result:
@@ -81,10 +81,10 @@ Instead of binding directly to a method name, we can also use methods in an inli
8181
Vue.createApp({
8282
methods: {
8383
say(message) {
84-
alert(message);
84+
alert(message)
8585
}
8686
}
87-
}).mount("#example-3");
87+
}).mount('#example-3')
8888
```
8989

9090
Result:
@@ -220,7 +220,7 @@ You can also [define custom key modifier aliases](TODO:../api/#keyCodes) via the
220220

221221
```js
222222
// enable `v-on:keyup.f1`
223-
Vue.config.keyCodes.f1 = 112;
223+
Vue.config.keyCodes.f1 = 112
224224
```
225225

226226
## System Modifier Keys

src/guide/forms.md

+42-35
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,39 @@ Multiple checkboxes, bound to the same Array:
7676
```
7777

7878
```js
79-
new Vue({
80-
el: '#example-3',
81-
data: {
82-
checkedNames: []
79+
Vue.createApp({
80+
data() {
81+
return {
82+
checkedNames: []
83+
}
8384
}
84-
})
85+
}).mount('#example-3')
8586
```
8687

8788
<forms-4/>
8889

8990
### Radio
9091

9192
```html
92-
<input type="radio" id="one" value="One" v-model="picked" />
93-
<label for="one">One</label>
94-
<br />
95-
<input type="radio" id="two" value="Two" v-model="picked" />
96-
<label for="two">Two</label>
97-
<br />
98-
<span>Picked: {{ picked }}</span>
93+
<div id="example-4">
94+
<input type="radio" id="one" value="One" v-model="picked" />
95+
<label for="one">One</label>
96+
<br />
97+
<input type="radio" id="two" value="Two" v-model="picked" />
98+
<label for="two">Two</label>
99+
<br />
100+
<span>Picked: {{ picked }}</span>
101+
</div>
102+
```
103+
104+
```js
105+
Vue.createApp({
106+
data() {
107+
return {
108+
picked: ''
109+
}
110+
}
111+
}).mount('#example-4')
99112
```
100113

101114
<forms-5/>
@@ -117,16 +130,13 @@ Single select:
117130
```
118131

119132
```js
120-
Vue.createApp().mount(
121-
{
122-
data() {
123-
return {
124-
selected: ''
125-
}
133+
Vue.createApp({
134+
data() {
135+
return {
136+
selected: ''
126137
}
127-
},
128-
'#example-select'
129-
)
138+
}
139+
}).mount('#example-select')
130140
```
131141

132142
<forms-6/>
@@ -163,21 +173,18 @@ Dynamic options rendered with `v-for`:
163173
```
164174

165175
```js
166-
Vue.createApp().mount(
167-
{
168-
data() {
169-
return {
170-
selected: 'A',
171-
options: [
172-
{ text: 'One', value: 'A' },
173-
{ text: 'Two', value: 'B' },
174-
{ text: 'Three', value: 'C' }
175-
]
176-
}
176+
Vue.createApp({
177+
data() {
178+
return {
179+
selected: 'A',
180+
options: [
181+
{ text: 'One', value: 'A' },
182+
{ text: 'Two', value: 'B' },
183+
{ text: 'Three', value: 'C' }
184+
]
177185
}
178-
},
179-
'#example-select-dynamic'
180-
)
186+
}
187+
}).mount('#example-select-dynamic')
181188
```
182189

183190
<forms-8/>

0 commit comments

Comments
 (0)