runtime-core.esm-bundler.js?d2dd:40 [Vue warn]: Property "$store" was accessed during render but is not defined on instance. at <App>
时间: 2023-11-18 16:56:39 浏览: 140
reactivity.esm-bundler.js
This warning message is related to the use of Vuex store in a Vue component. It indicates that the component is trying to access the `$store` property, but the store is not defined on the component instance.
To resolve this warning, make sure that you have properly installed Vuex and created a store instance, and then inject the store into your Vue app using the `store` option. For example, in your main.js file, you can create a store instance and inject it into the app:
```javascript
import Vue from 'vue'
import Vuex from 'vuex'
import App from './App.vue'
Vue.use(Vuex)
const store = new Vuex.Store({
// ...
})
new Vue({
store, // inject the store into the app
render: h => h(App)
}).$mount('#app')
```
Then, in your component, you can access the store using the `$store` property:
```vue
<template>
<div>
{{ $store.state.someState }}
</div>
</template>
<script>
export default {
// ...
}
</script>
```
阅读全文