Javascript 在Rails中设置Vuetify?
我在Rails应用程序中运行Vue 2.6.10和Vuetify 2.2.12,但在正确安装Vuetify时遇到问题 我得到以下错误:Javascript 在Rails中设置Vuetify?,javascript,ruby-on-rails,vue.js,vuejs2,Javascript,Ruby On Rails,Vue.js,Vuejs2,我在Rails应用程序中运行Vue 2.6.10和Vuetify 2.2.12,但在正确安装Vuetify时遇到问题 我得到以下错误: [Vuetify] Multiple instances of Vue detected Error: "Vuetify is not properly initialized, see https://vuetifyjs.com/getting-started/quick-start#bootstrapping-the-vuetify-object" [Vue
[Vuetify] Multiple instances of Vue detected
Error: "Vuetify is not properly initialized, see https://vuetifyjs.com/getting-started/quick-start#bootstrapping-the-vuetify-object"
[Vue warn]: Error in render: "TypeError: this.$vuetify is undefined"
以下是我的dashboard.js文件:
import Vuex from 'vuex'
import Dashboard from '../../assist/dashboard.vue'
import VueResource from 'vue-resource'
import TurbolinksAdapter from 'vue-turbolinks'
import Vuetify from 'vuetify'
import 'vuetify/dist/vuetify.min.css'
Vue.use(Vuex)
Vue.use(TurbolinksAdapter)
Vue.use(VueResource)
Vue.use(Vuetify)
window.store = new Vuex.Store({
state: {
organization: {},
},
mutations: {
}
})
document.addEventListener("turbolinks:load", function() {
Vue.http.headers.common['X-CSRF-TOKEN'] = document.querySelector('meta[name="csrf-token"]').getAttribute('content')
var element = document.querySelector("#assistdashboard")
if (element != undefined) {
const app = new Vue({
el: element,
store: window.store,
template: "<Dashboard />",
components: { Dashboard }
})
}
})
从“Vuex”导入Vuex
从“../../assist/Dashboard.vue”导入仪表板
从“vue资源”导入VueResource
从“vue turbolinks”导入TurbolinksAdapter
从“Vuetify”导入Vuetify
导入“vuetify/dist/vuetify.min.css”
Vue.use(Vuex)
Vue.use(TurbolinksAdapter)
Vue.use(VueResource)
Vue.use(Vuetify)
window.store=新的Vuex.store({
声明:{
组织:{},
},
突变:{
}
})
document.addEventListener(“TurboLink:load”,函数(){
Vue.http.headers.common['X-CSRF-TOKEN']=document.querySelector('meta[name=“CSRF-TOKEN”]”)。getAttribute('content'))
var元素=document.querySelector(“assistdashboard”)
if(元素!=未定义){
const app=新的Vue({
el:元素,
商店:window.store,
模板:“”,
组件:{Dashboard}
})
}
})
和my layout.vue文件:
<template>
<v-app id="dashboard-layout">
...
</v-app>
</template>
...
我尝试在dashboard.js
中的Vue初始化中添加vuewtify:new Vuetify(vuetifyOptions)
,但这并没有改变任何事情。我还尝试重新安装Vue和Vuetify,但也没有成功
有人有什么想法吗?我不知道它是否与您的问题有关,但您不应该像这样检查
未定义的,如果(typeof element!=='undefined'){}
是一种更好的语法,也许它可以帮助: