Loading.vue
<template>
<div v-show="show" class="container">
<div class="loading"></div>
</div>
</template>
<script>
export default {
name: "Loading",
data() {
return {
show: false
}
}
}
</script>
index.js
import LoadingComponent from './Loading'
const Loading = {}
Loading.install = function (Vue) {
const LoadingConstructor = Vue.extend(LoadingComponent)
const instance = new LoadingConstructor()
instance.$mount(document.createElement('div'))
document.body.appendChild(instance.$el)
Vue.prototype.$loading = {
show() {
instance.show = true
},
close(){
instance.show = false
}
}
}
export default Loading
main.js
import Loading from './components/loading/index.js'
Vue.use(Loading)
Vue.prototype上没有成功挂载到$loading,请问这是为什么
在
index.js
中引入 vue