您好,我正在尝试设置 view-spinner
,但出现错误:
那是我的主要JS(app.js):
import Vue from 'vue';
import App from './App.vue'
import axios from 'axios'
import router from './router'
import store from './vuex/store';
import PulseLoader from 'vue-spinner/src/PulseLoader.vue'
require('../scss/style.scss');
Vue.config.productionTip = false;
Vue.prototype.$http = axios;
new Vue({
el: '#vueApp',
router,
store,
template: '<App/>',
components: {
App,
PulseLoader
},
});
我的.vue <template>
<div class="app">
<pulse-loader :loading="loading" :color="color" :size="size"></pulse-loader>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<router-link class="nav-item" tag="li" to="/" active-class="active">
<a class="nav-link">Home</a>
</router-link>
<router-link class="nav-item" tag="li" to="/wow" active-class="active">
<a class="nav-link">Wow</a>
</router-link>
</ul>
</div>
</nav>
<router-view></router-view>
</div>
</template>
<script>
export default {
name: 'app',
data: () => {
return {
color: '#000000',
size: '1000px'
}
}
}
</script>
<style lang="scss">
</style>
谢谢你的帮助。 最佳答案
在数据对象中添加loading
属性并按如下所示导入模块:
import PulseLoader from "vue-spinner/src/PulseLoader.vue";
export default{
data: () => {
return {
color: '#000000',
size: '1000px',
loading:true
}
},
components:{PulseLoader}
...
}
或者您可以使用
computed
这样的属性: computed:{
loading(){ return true;}
}
你可以做任何你想做的事情,并返回一个带有
loading
名称的 bool(boolean) 值关于javascript - 未定义VueJS vue-spinner属性或方法 “loading”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52682506/