Data does not have this variable in vue, so why can it be printed out?

problem description

data does not have this variable in vue, so why can it be printed out?

the environmental background of the problems and what methods you have tried

related codes

/ / Please paste the code text below (do not replace the code with pictures)
data () {

return {
    name:"yy",
    age:16,
}

}
methods: {

this.weight=this.age
console.log(this.weight)
//this.weight

}

what result do you expect? What is the error message actually seen?

Oct.15,2021

try console.log (this) and see what's in this


personal opinion:
the current this points to the Vue instance, that is, it is equivalent to adding weight attributes directly to the Vue instance
similar to js,

abc = 100
console.log(abc)

the result is the same, you don't have let (var) abc, but you still add abc
to window, just a variable declaration, but there are some differences in vue
if you use {{weight}}
(template) in DOM, you should not update DOM
you can try

<template>
    <div id="mmm">
      <div>{{weight}}</div>
    </div>
</template>
created () {
    setTimeout(() => {
       this.weight = '123'
    }, 1000)
}

data is not defined. DOM is always empty. Initialize in data. 1 second later, DOM updates
, so all recommended data is initialized in data

.

this means that the current component
this is a json object
var test = {}
test.t = 123
console.log (test)
output result {t: 123}
this is an assignment
can you output data directly after assignment

?
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3749e-2c097.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3749e-2c097.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?