Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the page in a component of the watch throw error, the whole Vue hung up #3142

Closed
chaoren1641 opened this issue Jun 23, 2016 · 3 comments

Comments

@chaoren1641
Copy link

When the page in a component of the watch throw error, the whole Vue hung up

new Vue({
  el: '#app',
  data: {
    text: 1
  },
  methods: {
    add: function() {
        this.text++ 
    },
    undf: function() {
        var obj = {}
        this.text = obj.value
    }
  },
  watch: {
    text: function(newVal) {
        // Once reported here, Vue will hang up.
        if(newVal.toFixed(3)) {
        console.log('changed')
      }
    }
  }
})

this is reproduce the scene:

https://jsfiddle.net/chaoren1641/xognutk1/4/

@chaoren1641 chaoren1641 changed the title https://jsfiddle.net/chaoren1641/xognutk1/4/ When the page in a component of the watch throw error, the whole Vue hung up Jun 23, 2016
@yyx990803
Copy link
Member

This is not a bug, you have an uncaught error in user logic...

@yyx990803
Copy link
Member

Added the ability to use config.errorHandler to handle the error instead of throwing.

@chaoren1641
Copy link
Author

You're so efficient, so great.
Novices usually do not handle such errors in any place, such as when the data returned by the server is abnormal, this time the entire page of the Vue components will lose their jobs, I have encountered two such examples. Can throw a warning or frame level to avoid it is the best of course!

thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants