kartsims / vue-cordova

Vue.js plugin for Cordova
http://kartsims.github.io/vue-cordova
328 stars 71 forks source link

support : could you give more details to add plugin #25

Closed taha-azzabi closed 5 years ago

taha-azzabi commented 6 years ago

Hi, Could you you give more details to add plugin,please. 1) Clone the repo

2) Create a file named by the plugin in the plugins/ directory 3) Add your plugin to the list in src/index.js 4) Write a tiny doc in docs/_plugins/.md

5) How we re-generate the plugin vue-cordova to use it with our plugin.

thanks

valgaze commented 6 years ago

Still in the dark here, but this might help: https://stackoverflow.com/questions/43629684/add-cordova-plugins-to-vue-cordova

yijialuo commented 6 years ago

How to add additional plugins?Could you you give more details?thanks

yijialuo commented 6 years ago

How to add plugin to the list in src/index.js?

BiYuqi commented 5 years ago

https://github.com/BiYuqi/vue-cordova

migueldiganchi commented 5 years ago

How to add plugin to the list in src/index.js? Have you found the way of doing it? Regards!

valgaze commented 5 years ago

@migueldiganchi This plugin has been abandoned https://github.com/kartsims/vue-cordova/issues/28#issuecomment-403891710

If you're willing to avoid this library, as long as your application is properly initialized for Cordova (ie 'deviceready' has fired and cordova.js is included in the HTML file), you should be able to access registered Cordova plugins from vue components using the cordova.plugins (window.cordova.plugins) object.

Ex. Access barcode scanner scanner scan method:

cordova.plugins.barcodeScanner.scan((result) => {console.log(result)}, (err) => {console.err(error)});

If accessing through Vue is a hard requirement for some reason, in the root component's mounted lifecycle hook, you could attach Vue.prototype.$pluginName to cordova.plugins.pluginName and thereby make it accessible in child components as this.$pluginName

That said if you really want to use this library, look at the source and note:

migueldiganchi commented 5 years ago

@migueldiganchi This plugin has been abandoned #28 (comment)

If you're willing to avoid this library, as long as your application is properly initialized for Cordova (ie 'deviceready' has fired and cordova.js is included in the HTML file), you should be able to access registered Cordova plugins from vue components using the cordova.plugins (window.cordova.plugins) object.

Ex. Access barcode scanner scanner scan method:

cordova.plugins.barcodeScanner.scan((result) => {console.log(result)}, (err) => {console.err(error)});

If accessing through Vue is a hard requirement for some reason, in the root component's mounted lifecycle hook, you could attach Vue.prototype.$pluginName to cordova.plugins.pluginName and thereby make it accessible in child components as this.$pluginName

That said if you really want to use this library, look at the source and note:

Hello, and thank you for your answer. The problem is that my Vue.cordova.plugins array is empty. I want to install the cordova-sqlite-storage for Vue. After installing it and added as a plugin within Cordova, I'm able to access to vue-cordova. But I cannot get access to the plugin.

valgaze commented 5 years ago

@migueldiganchi Got it, I understand

What I'm saying is for your situation, skip this library entirely and use a Cordova plugin directly from your Vue components like this:

cordova.plugins.pluginName.methodName(params)

If the plugin is installed and by the time that Vue component has been mounted, cordova.js emits a deviceready event

kartsims commented 5 years ago

@valgaze thanks for your comment that is very helpful

It does make sense for people who struggle to include the plugin to just drop the lib completely since it's mostly a helper library

If you'd like to contribute, I'd be happy to have a section in the README with this kind of information. Something along the lines of "You can also access the cordova object without requiring this library by doing this and that. Support for individual plugins that are not mentioned can also be done by doing this and that.".

I believe people naturally search for a vue and cordova integration when starting such project, and find this repo.

It did make sense for me at the time I created this library, to help onboarding newcomers, but the feedback I am getting is that some get frustrated over the lack of integration to the many plugins out there and unfortunately I can't support them all by myself (testing takes a lot of time).

valgaze commented 5 years ago

@kartsims -- Great idea, I'll make a PR tonight

kartsims commented 5 years ago

Merged, thank you!