p2hacks2023 / pre-03

SINKEN
2 stars 1 forks source link

子コンポーネントから値が取れない #45

Closed kCat-fun closed 11 months ago

kCat-fun commented 11 months ago

出来た 親コンポーネント

<InputBox placeholder="メールアドレス" @onchange="(val) => {console.log(val)}"/>

子コンポーネント

<template>
    <div>
        <input :type="type" :placeholder="placeholder" v-model="value" @change="this.$emit('onchange', value)" />
    </div>
</template>

<script>
export default {
    name: "InputBox",
    data: () => {
        return {
            value: undefined,
        }
    },
    props: {
        type: {
            type: String,
            default: "text",
        },
        placeholder: {
            type: String,
            default: ""
        },
    },
}
</script>

<style lang="scss" scoped>
@import './index.scss';
</style>

image