• Welcome to Baben's blog that year. I'm glad to meet you at the right age!
  • Due to the theme, the QQ login partner displays the default avatar in the comments. Please go to the personal center to upload the avatar again.

How does Vue listen to the value in the object

Code Notes barben Five years ago (2019-09-25) 2370 views 0 comments

——Record this time that I took off my pants to fart in order to realize the internal value of the listener


When writing a bug today, I need to use the watch to monitor whether a value in the object has changed. I thought for a long time

 data() { return { register: { username: "" } } }

↑ Yes, I just want to watch the username

(Thinking a little)

 computed: { watchUsername() { return this.register.username; } }, watch: { watchUsername() { Console. log ("Yes, that's it!"); } }

The big guy sitting opposite me praised me directly: You're such a smart kid


I felt that something was wrong, and I decided to find a way

 watch: { 'register.username'() { Console. log ("This... bother you!"); } }

Is this what people do
Good bye!


Eight blogs that year, we have been
If the author does not indicate that it is an original article, please indicate the link and source of this article for reprinting
How does Vue listen to the value in the object- https://www.barben.cn/code/589.html
Like( eight )
Post my comments
Cancel comment
expression Mapping Bold Strike through Center Italic

You need to bring your nickname and email with you in the review of Eight Books that year!

  • Nickname (required)
  • Email (required)
  • website