问题
So, I am trying to use the pretty neat component vue-social-sharing but this is the first time I am using such a libaray and am not sure how to set it up properly.
I have installed it via NPM, but then get lost on the first section "Usage, Loading the library"
Specifically, it says
"Browserify / Webpack"
var SocialSharing = require('vue-social-sharing');
Vue.use(SocialSharing);
But, I am not exactly sure where that goes, how it is setup etc. Do I set it in some Webpack file somewhere? or create its own file and import? Or, if it is in a normal vue file, which level? per component, per view? on the App.vue level?
I just don't really understand how exactly to set this up.
Any help would be great, I am completely lost as this is my first time using external libraries like this.
Thanks!
回答1:
That code you should put it inside main.js
file which will initialize using that plugin (library):
import Vue from 'vue';
var SocialSharing = require('vue-social-sharing');
Vue.use(SocialSharing);
new Vue({
....
})
and the following code you could put it inside any child component template:
<social-sharing url="https://vuejs.org/" inline-template>
<div>
<network network="facebook">
<i class="fa fa-fw fa-facebook"></i> Facebook
</network>
....
</social-sharing>
来源:https://stackoverflow.com/questions/54147456/using-a-javascript-library-plugin-within-vue-code