search

Home  >  Q&A  >  body text

vuejs does not display the value within {{ }}, the text is displayed as is

<p>I developed a vuejs program and ran the <code>npxserve</code> command. I go into that directory and run npxserve. I browse <code>http://localhost:300/myvuefile.html</code> and only get the following output. {{count}} inside the button. My code: </p> <pre class="brush:php;toolbar:false;"><script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> ; <div id="app"> <button @click="count ">{{ count }}</button> </div> <script> import { createApp } from 'vue' const app = createApp({ data() { return { count: 0 } } }) app.mount('#app') </script></pre> <p>I have to get the value of the count and on click the count should be incremented. Instead, I only get {{count}} as output. Please help to resolve this issue. </p>
P粉797004644P粉797004644545 days ago625

reply all(1)I'll reply

  • P粉639667504

    P粉6396675042023-08-31 11:45:15

    According to documentation-

    So, either use -

    like this

    const app = Vue.createApp({
      data() {
        return {
          count: 0
        }
      }
    })
    
    app.mount('#app')
    <div id="app">
      <button @click="count++">{{ count }}</button>
    </div>
    
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>

    reply
    0
  • Cancelreply