用于商店的Ember.js外部json [英] Ember.js external json for Store

查看:42
本文介绍了用于商店的Ember.js外部json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个json文件,该文件位于托管Ember.js应用程序的服务器上.我想将该json用作应用程序的存储"(仅用于读取).我不确定执行此操作的最佳方法.我需要使用RESTAdapter来访问文件,还是以某种方式将其用作外部FixtureAdapter,还是有其他方法可以实现此目的?

I have a json file that lives on the on the server that is hosting my Ember.js app. I want to use that json as the "store" for the app (it will only be for reading). I'm not sure the best way to do this. Do I need to use a RESTAdapter to hit the file, or somehow use it as an external FixtureAdapter, or is there some other way to accomplish this?

推荐答案

您最好的选择是使用

Your best bet is to use the fixture adapter as described here. If the file is static, you can just add it to your page as a script tag and be done with it. If the file changes per user, you'll probably have to write some server-side logic to generate it. If that's the case, I would append it to your HTML file as a self executing function or something. Either way, if your data isn't changing, the FixtureAdapter is your best bet. You don't want to have to mess with the RESTAdapter or trying to write your own.

这篇关于用于商店的Ember.js外部json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆