2021-04-25から1日間の記事一覧

$emitメソッドで子コンポーネントから親コンポーネントに情報を渡す

<html lang="ja"> <head> <meta charset="UTF-8"> <title>Vue.js</title> </head> <body> <div id="app"> <p>現在値:{{ current }}</p> <my-counter step="1" v-on:plus="onplus"></my-counter> <my-counter step="2" v-on:plus="onplus"></my-counter> <my-counter step="-1" v-on:plus="onplus"></my-counter></div></body></html>

Vue.jsのテキストフィールドの値をEnterでリストに追加する

input type="text"に入力したデータがlistに追加されていくやつ。 <html lang="ja"> <head> <meta charset="UTF-8"> <title>Vue.js</title> </head> <body> <div id="app"> <form ref="form" @submit.prevent> <input type="text" @keydown.enter="trigger" v-model="message" placeholder="enter something..."/> </form> </div></body></html>