所以我通过商店将组件作为变量传递,例如
<template>
<div>
<component :is="store.state.General.body"></component>
</div>
</template>
<script>
import store from "@/store"
</script>
现在我想知道如何通过道具传递组件,因为我正在这样做:
<script>
import Input from "@/components/Input"
methods: {
example() {
store.commit("general_set_modal", {body: Input, title: "New "+page})
}
</script>
它被正确渲染,但缺少所需的道具。
答案 0 :(得分:1)
我做的事情
<template>
<div>
<component :is="store.state.General.body" v-bind="store.state.General.props"></component>
</div>
</template>
<script>
import store from "@/store"
</script>
并使商店项目看起来像
<script>
import Input from "@/components/Input"
methods: {
example() {
store.commit("general_set_modal", {body: Input, props: {title: "New "+page}})
}
</script>