Created
June 14, 2019 09:42
-
-
Save uguisu-an/6c80946359108890c8625898e12186c7 to your computer and use it in GitHub Desktop.
vue - 文字列の配列のv-model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<div v-for="(message, i) in messages" :key="i"> | |
<input type="text" :value="message" @input="e => input(i, e.target.value)" /> | |
</div> | |
</div> | |
</template> | |
<script lang="ts"> | |
import { Prop, Component, Vue } from "vue-property-decorator"; | |
@Component | |
export default class VueListInput extends Vue { | |
@Prop({ default: () => [] }) messages!: string[]; | |
input(i: number, message: string) { | |
this.messages.splice(i, 1, message); | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment