Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

130
Views
Vue3 object render invalid,but vue2 success

A simple demo

HTML Template

<div id="app">{{ temp.progress }}</div>

Instantiate object

class Temp {
    constructor () {
        this.start()
    }
    progress = 0

    start () {
        setInterval(() => {
            this.progress += 1
        }, 1000)
    }
}

const temp = new Temp()

vue2 render success (page display 1,2,3,4,5.......)

new Vue({
    el: '#app',
    data () {
        return { temp }
    },
})

but vue3 render invalid (page display always 0)

Vue.createApp({
    data() {
        return { temp }
    }
}).mount('#app')
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Vue 3 creates Proxy object rather than augmenting the original object in place. Conceptually you can think of it as (in vue3 code):

const dataObj = { temp };
const data = reactive(dataObj);

dataObj is your raw object and data is the proxy. They are two different objects. The important thing is that data is reactive, but dataObj is not. All the direct mutations on the dataObj cannot be observed, because the observing utilities are all in the stub methods of the proxy object.

What your Temp class is doing, effectively it is mutating the raw object - that is what this refers to.

If your component does not own its data, i.e. the data needs to be externalized and passed in, and will be managed (mutated) externally, you will need to create a reactive object and pass it into your component.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!