triniwiz / nativescript-pager

Apache License 2.0
90 stars 48 forks source link

fix: vue fix for model #190

Closed farfromrefug closed 4 years ago

farfromrefug commented 4 years ago

this fixes vue model handling And remove an unwanted log

tillsanders commented 3 years ago

Hi, I was trying to upgrade to v13.0.0-alpha.12 when I ran into an issue caused by the changes of this PR in src/vue/pager.js, line 94. The behaviour of the selectedIndexChange event was altered and it's not quite obvious to me why. Before, I would simply get the current index as a plain number in the payload of the event. Now I get an object, containing an object under the object key, which in turn contains the new index? What is the reasoning behind this? 🤔 If this is just a mistake, I can open a PR to fix it 🙂

For anyone else experiencing this issue and looking for a solution: This change led to the following error: Invalid prop: type check failed for prop "selectedIndex". Expected Number with value NaN, got Object because I was "piping" the payload directly to the variable that would also set the selectedIndex prop to establish a two-way sync. To fix this, I simply adapted how I handled the selectedIndexChange event: @selectedIndexChange="index = $event" → @selectedIndexChange="index = $event.object.selectedIndex".

farfromrefug commented 3 years ago

@tillsanders indeed had to fix it correctly handle v-model. Sorry for the trouble!

tillsanders commented 3 years ago

Sry, I'm a bit confused 😄 So this is a mistake, right? Because the v-model directive is also not working this way.

farfromrefug commented 3 years ago

@tillsanders it is working perfectly here like that with N 7. However be careful on production build you need to register v models in your webpack file! https://github.com/cairn-monnaie/CairnMobile/blob/master/cairn_mobile_end_user/app.webpack.config.js#L14

tillsanders commented 3 years ago

@farfromrefug Good point, now it's working! What has webpack got to do with it though?

farfromrefug commented 3 years ago

@tillsanders it is because of the way nativescript-vue compile templates in prod. It needs to know about the model on "compilation" or it wont work. Thus the need to register inside the webpack