Is it wrong for vue to deconstruct the assignment like this?

data is like this

data () {
    return {
      username: "",
      pw: "",
      pw2: ""
    }
}

then in a method of methods, is it wrong to deconstruct the assignment like this? this points to the current component. Can"t I print the username to show that it is empty

?
const {username, pw, pw2} = this
Jan.24,2022

this deconstruction can only be used in vue to obtain assignments that cannot be operated because it is a value

const {username, pw, pw2} = this

username = '123'//

if you're just using it for printing, maybe username is asynchronously assigned

.
this.username = ''
const {username, pw, pw2} = this
consloe.log(username) // 

has actually been deconstructed. It is empty because your initial value is empty. You can set a username value to see

.

is already an empty string. If you can't get it, it should be undefined


say what you need, what do you want to achieve

Menu