One of the advantages of webpack is that you can make the module available in all of your files. In Vue.js, we talk about components. So what you did is that you use the jQuery module in your component and it will be available only in that component. To make it global, add webpack to your configuration file:
webpack.base.conf.js
var webpack = require("webpack")
module.exports = {
plugins : [
new webpack.ProvidePlugin({
$ : "jquery",
jQuery : "jquery"
})
],
};
webpack. jQuery , :
Vue
<template>
<input type='checkbox' id="toggle-checked" v-model="active">
</template>
<script type="text/babel">
require('bootstrap-toggle')
export default {
data () {
return {
active: 1
}
},
mounted: function () {
$('#toggle-checked').bootstrapToggle()
}
}
</script>
- , CSS, , Webpack . , Webpack .