我想使用浏览器的默认行为,使用Ember在新选项卡中打开pdf文件。
我没有使用Ember-Data,而是使用Python作为服务器端资源。因此,我在Ember启动时将代理地址设置为指向服务器端地址。
我建立了一个路线页面,并且有一个链接可以在浏览器中打开PDF文件,例如
<a href="/path/apps/list.pdf?list=current" target="_blank">Open</a>
服务器的Python资源返回一个pdf:
@get("/list.pdf")
@params(C.String("list"))
def get_list_pdf(list):
//some code to build the pdf string
Response(pdf_string, headers={'Content-Type': 'application/pdf'})
我在没有余烬的应用程序中尝试过从链接访问资源,这很好。但是使用Ember,我无法做到这一点。
我收到此错误:未捕获的UnrecognizedURLError:/path/apps/list.pdf?list=current ember.debug.js:4914
有什么建议我可以实现吗?
为了解决我的问题,我创建了一条新路线,并将html object元素添加到其模板中。我还添加了{{链接到“路线”(query-params url ='the url')}},以过渡到该路线以呈现PDF。
template.hbs
<object data={{url}} type='application/pdf' />
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句