问题描述
我试图添加动态片段,这应该是我的应用程序可选的,首先我不知道他们不可以使用:param语法,我开始从我的所有模板中得到一个奇怪的非描述性错误事情
I tried to add dynamic segment which should be optional for my app, first thing is I didn't know they cannot be optional with the :param syntax, and I started getting a strange non descriptive error out of my templates of all things
Uncaught TypeError: Cannot read property 'shouldSupercede' of undefined
我花了一个多小时才意识到发生了什么,不管我有多少尝试使用* param和(:param)来配置参数,但是我可以不是。
It took me over an hour to realize what's going on and no matter how much I tried to make the param optional with *param and (:param), but I could not.
这是一个巨大的问题。如果有人知道这样做的正确方法,我将非常感激。
This is a huge problem. If anyone knows the proper way to do this I'll be very grateful
推荐答案
你可以使用嵌套的资源(测试版本1.8 .1):
You could use nested Resources (Tested with Version 1.8.1):
this.resource('profile-root', {
path:'/profile'
},function(){
this.resource('profile', {
path : ':id'
});
});
所以当您导航到/ profile时,将使用此路由:
So when you navigate to „/profile" it will use this Routes :
- profile-root
- profile-root.index
当您导航到/ profile / 1:
And when you navigate to /profile/1:
- profile-root
- 个人资料
- profile.index
这篇关于Ember中是否有可选动态段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
- 个人资料