Skip to content

emitの指定をcamelに修正した(原文に追従) #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/api/instance-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
```

```js
const app = Vue.createApp({
const app = createApp({
methods: {
sayHi() {
console.log('Hi!')
Expand All @@ -201,6 +201,7 @@
})

app.component('welcome-button', {
emits: ['welcome'],
template: `
<button v-on:click="$emit('welcome')">
Click me to be welcomed
Expand All @@ -215,12 +216,12 @@

```html
<div id="emit-example-argument">
<advice-component v-on:give-advice="showAdvice"></advice-component>
<advice-component v-on:advise="showAdvice"></advice-component>
</div>
```

```js
const app = Vue.createApp({
const app = createApp({
methods: {
showAdvice(advice) {
alert(advice)
Expand All @@ -229,6 +230,7 @@
})

app.component('advice-component', {
emits: ['advise'],
data() {
return {
adviceText: 'Some advice'
Expand All @@ -237,12 +239,14 @@
template: `
<div>
<input type="text" v-model="adviceText">
<button v-on:click="$emit('give-advice', adviceText)">
<button v-on:click="$emit('advise', adviceText)">
Click me for sending advice
</button>
</div>
`
})

app.mount('#emit-example-argument')
```

- **See also:**
Expand Down
6 changes: 3 additions & 3 deletions src/guide/component-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ app.component('blog-post', {
そして子コンポーネントはビルトインの [**`$emit`** メソッド](../api/instance-methods.html#emit)にイベントの名前を渡して呼び出すことで、イベントを送出することができます:

```html
<button @click="$emit('enlarge-text')">
<button @click="$emit('enlargeText')">
Enlarge text
</button>
```
Expand All @@ -252,7 +252,7 @@ app.component('blog-post', {
```js
app.component('blog-post', {
props: ['title'],
emits: ['enlarge-text']
emits: ['enlargeText']
})
```

Expand All @@ -263,7 +263,7 @@ app.component('blog-post', {
イベントを特定の値と一緒に送出すると便利な場合があります。例えば、テキストをどれだけ大きく表示するかを `<blog-post>` コンポーネントの責務とさせたいかもしれません。そのような場合、 `$emit` の第二引数を使ってこの値を渡すことができます:

```html
<button @click="$emit('enlarge-text', 0.1)">
<button @click="$emit('enlargeText', 0.1)">
Enlarge text
</button>
```
Expand Down
2 changes: 1 addition & 1 deletion src/guide/component-custom-events.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ this.$emit('myEvent')

```js
app.component('custom-form', {
emits: ['in-focus', 'submit']
emits: ['inFocus', 'submit']
})
```

Expand Down