vuex报错:Property or method “$store“ is not defined on the instance but referenced during render.

在vue2中使用vuex,配置时遇到的问题。

1.Uncaught TypeError: __WEBPACK_IMPORTED_MODULE_1_vuex__.a.store is not a constructor

在store\index.js中,创建实例时,应该大写Store,vuex内部定义的大写。

const store = new Vuex.Store({

2.Property or method "$store" is not defined on the instance but referenced during render.

vuex的版本不对,获取不到store。vue3只能用vuex4版本,vue2只能用vuex3版本。

2022年2月7日之后,vue3成了默认版本,vuex4相应的也成了默认版本,vuex4只能在vue3中使用。所以对于vue2,就不能默认下载最新版本了,要

npm install vuex@3 -- save 

3. Cannot read property 'state' of undefined"

在mian.js 中,创建实例时,store应该小写,也可以写成store:Store

new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})


 

<template> <div> <input type="text" v-model="searchId" placeholder="请输入sample_id"> <button @click="search">搜索</button> <el-table ref="multipleTable" :data="filteredData" tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange"> <el-table-column type="selection" width="55"></el-table-column> <el-table-column prop="sample_id" label="sample_id" width="120"> <template slot-scope="scope">{{ scope.row.sample_id }}</template> </el-table-column> <el-table-column prop="feature0" label="feature0" width="120"></el-table-column> <el-table-column prop="feature1" label="feature1" width="120"></el-table-column> <el-table-column prop="feature2" label="feature2" width="120"></el-table-column> <el-table-column label="操作" fixed="right" width="135"> <template slot-scope="scope"> <el-button type="text" @click=handleEdit(scope.$index)>编辑</el-button> <el-button type="text" @click="deleteRow(scope.$index)">删除</el-button> </template> </el-table-column> </el-table> </div> </template> <script> export default { data() { return { searchId: '', tableData: [], // your table data array filteredData: [] // array to store filtered data } }, methods: { search() { if (this.searchId.trim() === '') { this.filteredData = this.tableData; // if searchId is empty, show all data } else { this.filteredData = this.tableData.filter(item => { return String(item.sample_id).includes(this.searchId); }); } } } } 报Property or method "searchId" is not defined on the instance but referenced during render.怎么解决
07-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值