我是初学者vue。我使用vue cli。这是我的代码。
App.vue:
<template>
<div id="App">
<Count/>
</div>
</template>
<script>
import Count from './components/Count';
export default {
name:'App',
components:{
Count
}
};
</script>
Count.vue:
<template>
<div id="App">
<button @click="increase">{{count}}</button>
</div>
</template>
<script>
import {store} from './store/store.js';
export default {
name:'App',
computed:{
count(){
return store.state.count;
}
},
methods:{
increase(){
store.state.count++;
}
}
};
</script>
main. js:
import Vue from 'vue'
import App from './App.vue'
Vue.config.productionTip = false
new Vue({
render: h => h(App)
}).$mount('#app')
当我运行服务, 它编译失败,说: 未找到模块。错误,无法解析'.store.js'。无法解析'.store.js'。.
我需要有人来帮助我。
对不起,我发现错误。我发现了错误,这是我的粗心造成的,我用错误的路径导入组件。