我的vue應用程序有一個側欄,我想顯示一個組件作爲它的子。在vuex中提交組件
我想通過使用vuex存儲提交它傳遞組件,但它似乎無法正常工作。
我使用v-html
來測試側邊欄組件是否可以顯示子組件。
<div v-if="rightPanelOpen" class="right-panel" v-html="rightPanelComponent"></div>
計算財產(rightPanelComponent):
rightPanelComponent() {
if(this.$store.state.boardRightPanel.component === false) {
return "<div style='display: flex; align-items: center; justify-content: center; flex-grow: 1; height: 100%;'>Nothing found.</div>"
} else {
return this.$store.state.boardRightPanel.component
}
},
我犯這樣的子組件,
import About from '@/components/boards/post/About'
created() {
document.title = 'loading ...'
this.$store.commit('toggleRightPanel', true) // This will show the sidebar
this.$store.commit('rightPanelContent', About) // This is where i am trying to send the child component for the sidebar
},
我怎麼能在這個側邊欄顯示一個子組件場景?