dongyun3335 2019-04-15 12:38
浏览 95

在没有额外的ajax请求的情况下将laravel数据转换为vuex状态?

in my apps in order to get global data from laravel into my vue components I had a route middleware where I get global data from my eloquent queries, then I shared this data with my views and passed the data as props into each component, this has proven to work really good so far but can become a bit tricky when I have nested components (one component inside another), obviously I thought having a Globals vuex module would solve this.

I could call a vuex action which could make an ajax request to my global variables endpoint and populate my state each time the vue instance is created but that would mean an extra ajax request to my backend which I generally avoid.

My second idea is having a navbar component which an ajax request to fetch globals on mounted hook, this component would teorically be loaded first and populate my state, not sure if this would work to be honest.

Any ideas?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 八爪鱼爬数据为什么自己停了
    • ¥15 交替优化波束形成和ris反射角使保密速率最大化
    • ¥15 树莓派与pix飞控通信
    • ¥15 自动转发微信群信息到另外一个微信群
    • ¥15 outlook无法配置成功
    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率