vue3中的store模式, 应该怎么写computed, 才有响应式 ?

interface Store {
  selLeaderBoardItemKey: 'tradeStatisticsRef'; // 统计排行榜选中的key
  period: string; // 日期具体值
  periodType: PeriodType; // 日期类型
}
export const store: Store = reactive({
  selLeaderBoardItemKey: 'tradeStatisticsRef',
  period: '',
  periodType: 3
});
export const statisticsType = computed(() => {
  const statisticsTypeMap = {
    tradeStatisticsRef: 1
  };
  console.log('store.selLeaderBoardItemKey', store.selLeaderBoardItemKey);
  return statisticsTypeMap[store.selLeaderBoardItemKey] as StatisticsType;
});

上面这样写不行, 放在store里面也不行

阅读 1.1k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题