CuamckuyKot

Joined

50 Experience
0 Lessons Completed
0 Questions Solved

Activity

Posted in Vue: share the same bootstrap across multiple files

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.

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

© 2024 GoRails, LLC. All rights reserved.