【发布时间】:2018-11-04 20:54:43
【问题描述】:
对不起,我的英语不好。 我已经从 vue 中选择了道具。我想通过 props 值获取状态选择项。
我来自组件。
<template>
<h1>this.$store.state.fromSelected</h1>
</template>
<script>
export default {
props: ['fromSelected']
}
</script>
像这样处于vuex状态
const state = {
'one': null,
}
我像这样在根组件中使用我的 from 组件
<from from-selected="one"></from>
当我使用 this.$store.state.fromSelected 时,我想从组件中获取 this.$store.state.one。
【问题讨论】:
-
你能做任何现场演示吗?
-
通过在线编辑器或视频?
-
在代码 sn-p 中
-
查看我前几天回答的这个问题的答案;它解释了如何在当前组件中获取存储对象状态stackoverflow.com/questions/50489786/…
-
你的意思是这样的吗:jsfiddle.net/vngrcu5v