1

I would like, to capture the value of my input and display on another div.

Look my code :

If you look the code, I save the value in function msgFunc, and after that I would apply this result in my variable msg, but I don't understand.

export default {
        data () {
            return {
                msg: ''
            }
        },
        computed: {
            msgFunc: () => {
                return this.value
            }
        }
    }
.flex {
        display: flex;
        flex-flow: row wrap;
        justify-content: center;
        align-items: center;
        height: 90%;
    }
    .input-container {
        width: 410px;
        background-color: #fff;
        padding: 2px 15px 20px 15px;
        box-shadow: 0 16px 24px 2px rgba(0,0,0,0.14), 0 6px 30px 5px rgba(0,0,0,0.12), 0 8px 10px -5px rgba(0,0,0,0.3);
        transition: transform .1s ease-in-out;
    }
    .input-container input {
        margin-top: 10px;
        width: 100%;
        border-bottom: 1px solid #25A3FF;
        padding: 10px 0;
        font-size: 16px;
        color: #929292;
    }
    input:focus {
        outline: none;
    }
<div class="flex">
        <section class="input-container">
            <input type="text" v-model="msg" @change="msgFunc" placeholder="Type your HEX color">
            <h3>{{msg}}</h3>
        </section>
    </div>

1
  • v-model is already updating the value of msg on its own. I'm not sure what you're trying to accomplish Commented Aug 15, 2017 at 17:00

1 Answer 1

1

Just delete the computed property msgFunc and the @change attribute I made a fiddle where it works https://jsfiddle.net/50wL7mdz/53734/

if you want to trigger something with @change, please use the methods section, not computed.

Sign up to request clarification or add additional context in comments.

1 Comment

Possibly want the .lazy modifier. Hard to tell from the original post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.