HerringtonDarkholme / av-ts

A modern, type-safe, idiomatic Vue binding library
MIT License
216 stars 11 forks source link

[request for support] Would you be willing to see if you can get this to work Nuxt.js? #41

Closed Evertt closed 7 years ago

Evertt commented 7 years ago

I like Nuxt.js very much and I was wondering if it would be possible to use av-ts in a Nuxt.js project. I've been trying to get it to work, but I get Cannot convert undefined or null to object. (unfortunately without a stack trace)

edit

Okay I figured out where the error comes from. Nuxt.js changes the data() {} option in such a way that this is not available anymore. Which goes wrong in the collectData() method of this library, because it does let vm = this and then a bit later on for (let key of Object.keys(vm)) { ... } which of course doesn't work if this is undefined.

Evertt commented 7 years ago

Never mind, I rewrote the collectData() method and now it works. :-)

HerringtonDarkholme commented 7 years ago

I think this incompatibility lies in nuxt.js.

Nuxt.js changes the data() {} option in such a way that this is not available anymore.

this is required in data method because we may need props to initialize data. I do think we need to fix in nuxt.js, though I don't know why nuxt does so.

HerringtonDarkholme commented 7 years ago

https://nuxtjs.org/guide/async-data This is documented in nuxt's website. I think you should use @Data decorator.

HerringtonDarkholme commented 7 years ago

I will guard against this naughty behavior.

Warning: incompatible data option is a pernicious design, use it on your own discretion.

HerringtonDarkholme commented 7 years ago

Fixed in 0.6.3