0

I started my VueJS template using 'vue init webpack learning', this is the most basic setup as I am not using any tools from the package, just no to all tools.

Completed the template download, I just remove all unnecessary elements and start placing as follow:

<script>
export default {
  name: 'app',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
    }
  },
 }
</script>
<template>
  <div id="app">
    <img src="./assets/logo.png">
    <h1>{{ msg }}</h1>
    <!-- vmodel input -->
    <input v-model="message" type="text" placeholder="Enter a Message" />
    <p>Message is: {{ message }}</p>
    <!-- ^ the {{ message }} above is not updating in the browser as it is running in 'npm run dev' -->
  </div>
</template>

as I have commented above, the {{ message }} is not updating as I am typing on my 'npm run dev' environment, even another running mode.

How can I fix that? I uninstalled and installed NPM again and again, not to mention removes 'home brew' and install NodeJS again and again, it is not working.

Some help me with this thing, it is frustrating for beginners like me.

4
  • 2
    You're missing "message" in data Commented Mar 18, 2020 at 15:23
  • you have msg in data, but you donot have message as the data property Commented Mar 18, 2020 at 15:24
  • also pls post the err you are getting Commented Mar 18, 2020 at 15:25
  • vuejs.org/v2/guide/reactivity.html Commented Mar 18, 2020 at 15:28

1 Answer 1

4

Have you tried defining message in the data portion of your script?

<template>
  <div id="app">
    <img src="./assets/logo.png">
    <h1>{{ msg }}</h1>
    <!-- vmodel input -->
    <input v-model="message" type="text" placeholder="Enter a Message" />
    <p>Message is: {{ message }}</p>
    <!-- ^ the {{ message }} above is not updating in the browser as it is running in 'npm run dev' -->
  </div>
</template>

<script>
export default {
  name: 'app',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App',
      message : ""
    }
  },
 }
</script>

I'd recommend reading vuejs guide you can find it here If you want to directly read about how components work, here

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

Comments

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.