Skip to main content
Ask A Question
Notifications
You’re not receiving notifications from this thread.
Subscribe

Vue: share the same bootstrap across multiple files

Javascript • Asked by CuamckuyKot

Hi, guys!

I'm tired to copy-paste the same piece across multiple files.

import Vue from 'vue/dist/vue.js'
import VueResource from 'vue-resource'
import TurbolinksAdapter from 'vue-turbolinks'
import vueFilter from 'vue-filter'
Vue.use(TurbolinksAdapter)
Vue.use(VueResource)
Vue.use(vueFilter)
Vue.http.headers.common['X-CSRF-Token'] = document.querySelector('meta[name="csrf-token"]').getAttribute('content')

Vue.mixin({
    data(){
        return {
            routes: Routes,
            current_user: gon.current_user,
        }
    }
})

Is there any trick to share the same piece of javascript across multiple js files to follow DRY.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 29,763+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.