问题描述
当我单击$ model.show('demo-login')按钮时,控制台中始终出现以下错误:
usersFollowSuccess: (state,action) => {
const userId = action.payload._id;
const filtered = state.data.filter((user) => {
return user._id !== userId;
});
return {
...state,data: [...filtered,action.payload].sort(sortFunc),// Here
error: false,loaded: true,};
},
单击按钮即可获得完整输出:
TypeError: Cannot read property 'show' of undefined
我的代码:
product.vue
TypeError: Cannot read property 'show' of undefined
at click (product.vue?1da5:1)
at ie (vue.runtime.esm.js:1854)
at HTMLButtonElement.i (vue.runtime.esm.js:2179)
at HTMLButtonElement.Jr.a._wrapper (vue.runtime.esm.js:6917)
re @ vue.runtime.esm.js:1888
ne @ vue.runtime.esm.js:1879
ee @ vue.runtime.esm.js:1839
ie @ vue.runtime.esm.js:1862
i @ vue.runtime.esm.js:2179
Jr.a._wrapper @ vue.runtime.esm.js:6917
Main.js
<template>
<div class="app">
<demo-login-modal/>
<button @click="$model.show('demo-login')">PP</button>
</div>
</template>
<script>
import DemoLoginModal from '@/components/Modal_Login.vue';
export default {
name: 'product',components: {
DemoLoginModal,},};
</script>
Model_login副本中的弹出窗口
GitHub问题:https://github.com/euvl/vue-js-modal/issues/609
解决方法
我不确定,但我想你在这里打错了
<button @click="$model.show('demo-login')">PP</button>
更改为
<button @click="$modal.show('demo-login')">PP</button>