查询字符串参数中的句点中断Aurelia路由

编程入门 行业动态 更新时间:2024-10-27 10:23:28
本文介绍了查询字符串参数中的句点中断Aurelia路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试将电子邮件地址作为查询字符串参数传递给Aurelia路由.

I'm trying to pass an e-mail address as a query string parameter to an Aurelia route.

URL看起来像: localhost/some/route?email=john@doe

但是,URL中的点(句点)似乎中断了Aurelia路由,导致了 404 .

However, it seems the dot (period) in the URL breaks the Aurelia route, resulting in a 404.

如果我删除了点,则路由加载就很好了.

If I remove the dot, the route loads just fine.

任何想法是什么原因造成的?令我惊讶的是我找不到任何信息,路线中的句点应该很常见?

Any ideas what's causing this? I'm surprised I can't find any information on it, having periods in a route should be fairly common?

谢谢!

似乎这可能不是Aurelia问题,而是ASP.NET MVC问题: URL中的点导致使用ASP.NET mvc和IIS的404

Seems this may not be an Aurelia issue, but rather an ASP.NET MVC issue: Dots in URL causes 404 with ASP.NET mvc and IIS

推荐答案

在以下基本设置中似乎可以正常使用.我将其与最新的Aurelia CLI(v0.23)结合在一起.在此设置中,有三个文件:视图(html),视图模型(ts)和路线(app.ts):

It seems to work fine with the basic setup like below. I've whipped this up together with the latest Aurelia CLI (v0.23). In this setup there are three files: the view (html), the viewmodel (ts) and the route (app.ts):

views/edit-dots.html

<template> <p>email: ${email}</p> </template>

视图/edit-dots.ts

export class EditDots { public email; activate(params: any) { console.log('here are *all* your parameters: ', params); this.email = params.email; } }

最后,路由配置(在我的情况下为 app.ts ):

And finally, the route config (in app.ts in my case):

import { Router, RouterConfiguration } from 'aurelia-router' export class App { router: Router; configureRouter(config: RouterConfiguration, router: Router) { config.title = 'Stack'; config.map([ { route: ['', 'home'], name: 'home', moduleId: './views/home', nav: true, title: 'Home' }, { route: 'dots/:id', name: 'edit-dots', moduleId: './views/edit-dots', nav: false, title: 'Create a dot' } ]); this.router = router; } }

当我导航到 localhost:9001/#dots/42?email=harry@potter 使用此设置,它可以整齐地显示电子邮件地址.当然,我可以删除"42",仅用于演示目的.

When I navigate to localhost:9001/#dots/42?email=harry@potter with this setup, it neatly displays the email address. Of course, I can remove the '42', it is just for demonstration purposes.

最后一点,您的示例网址似乎未使用#号.如果这是故意的,则可能需要提供有关配置的更多详细信息.否则,对添加它有帮助吗?

Final note, your example url doesn't seem to use the #-sign. If this is intentional, you might want to give some more details about your configuration. Otherwise, does it help adding it?

也许这对您也有帮助?

更多推荐

查询字符串参数中的句点中断Aurelia路由

本文发布于:2023-11-13 01:18:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583009.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:句点   路由   字符串   参数   Aurelia

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!