Errors in Vue Development

Some problems and solutions I encountered during the use of vue.

Posted by Dusign on 2019-12-21
Words 123 and Reading Time 1 Minutes
Viewed Times

1、Problem: (TypeScript)using a.b or this.b

ERROR: property 'b' does not exist on value of type

Solution: change a or this to (a as any) or (this as any)

2、Problem: using js or jquery to modify DOM’s css value doesn’t work

Solution: mount Js functions in mounted instead of created

3、Problem: DOM does not change after changing data

Solution: using this.$set(Object, 'key', value) instead of this.Object.key = value

4、Problem: (TypeScript)using
document.getElementsByClassName('CLASS_NAME')[key].style.ATTRIBUTE = VALUE or document.querySelector('.CLASS').style.ATTRIBUTE = VALUE

ERROR: property 'style' does not exist on type 'Element'.Vetur(2339)

Solution: usign (document.querySelector('.CLASS') as HTMLElement).style.ATTRIBUTE = VALUE; or jQuery

If you like this blog or find it useful for you, you are welcome to comment on it. You are also welcome to share this blog, so that more people can participate in it. If the images used in the blog infringe your copyright, please contact the author to delete them. Thank you !