angular - angular 6 如何获取相对于字符串的 url
问题描述
我有当前页面的 url 字符串
使用_router.url
> localhost:4200/School/12300/Demography/12345
但我需要从 Demography 中删除 url 的结尾,直到结束,如:
> localhost:4200/School/12300
我怎么能简单地做到这一点?(没有 split 和 foreach 功能)
解决方案
最后,我意识到我可以使用相对路径"../../"
即使我没有完整的路径,这也可以始终有效。
谢谢!
推荐阅读
- python-3.x - 组合 2 个数字时缺少情节标题
- php - 发布请求在 while 循环中不起作用
- c# - 使用 C# System.Text.Json 对带有混合大小写的属性名称的 json 文本进行序列化/反序列化
- python - 如何在文本文档中找到所有单词
- ruby-on-rails - Rails 在编辑视图中选择复选框
- javascript - 根据条件从数组对象中获取键值对的数据
- oracle - SQL Loader 安装过程
- php - Laravel v8.x - Jetstream Inertia,419 页面在生产中过期
- javascript - 如果不可变列表包含空值,则禁用按钮
- javascript - 在 Vue 2 中轻松地将事件从子组件传递给父组件