[Vuejs]-How to set initial value of input in scoped-slot?

0👍

v-model will ignore the initial value, checked, or selected attributes found on any form elements. It will always treat the Vue instance data as the source of truth. You should declare the initial value on the JavaScript side, inside the data option of your component.

…docs

The fact you are using scoped-slot here is absolutely irrelevant…

Only way is to somehow initialize the value of ex.param data. One option is to use prop

<template>
    <slot :ex="ex"></slot>
</template>

<script>
    export default {
        props: ['initValue']
        data() {
            return {
                ex: {
                  param: this.initValue
                }
            }
        },
    }
</script>

Leave a comment