我在 popover 组件中使用 mixin,每次我尝试用它打开 popover 时,我都会得到:
runtime-core.esm-bundler.js?5c40:1667 Uncaught (in promise) TypeError: Cannot read property '__props' of undefined
at normalizePropsOptions (runtime-core.esm-bundler.js?5c40:1667)
at extendProps (runtime-core.esm-bundler.js?5c40:1678)
at Array.forEach (<anonymous>)
at normalizePropsOptions (runtime-core.esm-bundler.js?5c40:1690)
at createComponentInstance (runtime-core.esm-bundler.js?5c40:6309)
at mountComponent (runtime-core.esm-bundler.js?5c40:4102)
at processComponent (runtime-core.esm-bundler.js?5c40:4094)
at patch (runtime-core.esm-bundler.js?5c40:3712)
at mountChildren (runtime-core.esm-bundler.js?5c40:3894)
at mount (runtime-core.esm-bundler.js?5c40:4968)
popover function.vue:(我在这个脚本中没有使用 TS)
async openPopoverMetadata(e) {
const popover = await popoverController
.create({
component: formActions,
componentProps: { list: 'metadata' },
event: e,
animated: false,
translucent: true
})
return popover.present();
},
popover component.vue:
<template>
...
</template>
<script>
import { defineComponent } from 'vue';
import modalMixin from '@/components/mixins/modalMixin'
export default defineComponent({
name: 'formActions',
mixins: [ modalMixin ],
props: {
list: {
type: String,
default: ''
}
}
});
</script>
mixin.ts:只是一个简单的 mixin,我可以在其中进行模态调用
import { modalController } from '@ionic/vue'
import addCategoryModal from '@/components/modals/addCategoryModal.vue'
export default {
methods: {
async addCategoryModal() {
const modal = await modalController
.create({
component: addCategoryModal,
backdropDismiss: false,
})
return modal.present();
},
}
}
我在 vue 中使用 ionic,我的依赖项:
"@ionic/vue": "^5.6.0-dev.202102221703.5300dcc",
"@ionic/vue-router": "^5.6.0-dev.202102221703.5300dcc",
"vue": "^3.0.0-0",
"vue-router": "^4.0.0-0",
"vuex": "^4.0.0-rc.2",