我正在使用pushState,而不是对URL结构使用哈希。
我有一条路线,它有一些参数绑定-一些可选的:
route: [
'chart/:chartType/:id',
'chart/:chartType/:id/:view?',
'chart/:chartType/:id/page/:page?',
'chart/:chartType/:id/:view?/page/:page?'
],
Run Code Online (Sandbox Code Playgroud)
然后我有了我的route-href,并且在那儿有必要的绑定:
route-href="route.bind: chart; params.bind: { id: chartId, chartType: type, view: viewType, page: pageNum }"
...但是如果我不总是想要一个的所有路由参数route-href怎么办?与之类似,我希望能够仅链接到使用chartType和id的路由,而不必为此路由上的每个参数组合创建单独的路由。
我知道我可以使用“?” 在路由器配置中指定路由可选,但是如何在我的route-href链接中使参数可选?
做这样的事情会引发错误:
route-href="route.bind: chart; params.bind: { id: chartId, chartType: type, view?: viewType, page?: pageNum }"
而且我似乎无法使用这样的.bind语法(这也会出错):
route-href="route.bind: chart; params.bind: { id: chartId, chartType: type, view.bind: hasViewParam, page.bind: hasPageParam }"
这是什么神奇的语法技巧?
从语义上讲,有没有在今天的网站的适当位置(晚2008+),其中使用粗体<b>和斜体<i>标签比更广泛的应用更加有用<strong>和<em>标签?