- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
vue-router 文档没有涉及这个主题。
也许我对 vue-router 可以处理这个的期望说明了我对子域如何运作的根本误解。
这可以由 vue-router 处理吗,如果可以,如何处理,如果不能,为什么不可以?
最佳答案
我在为客户设置多个子域时遇到了同样的问题。
作为@mzgajner确实提到它不是直接
可能的。
但我想向您展示一个简单的 hacky 配置,它可以帮助您设置 Vue.js 应用程序在多个子域上工作。
您可以在 javascript 或 HTML 的 anchor 标记
中使用 window.location
将您的应用程序重定向到您的子域。然后设置你的 vue-router 来处理新路由。
我做了 this GitHub repo它在 3 个不同的子域上运行。
在此 GitHub 存储库中,查看 this file .它显示了为不同子域设置不同路由的简单配置。
import Vue from 'vue';
import App from './App';
import index from './router';
import route1 from './router/route1';
import route2 from './router/route2';
Vue.config.productionTip = false;
const host = window.location.host;
const parts = host.split('.');
const domainLength = 3; // route1.example.com => domain length = 3
const router = () => {
let routes;
if (parts.length === (domainLength - 1) || parts[0] === 'www') {
routes = index;
} else if (parts[0] === 'route1') {
routes = route1;
} else if (parts[0] === 'route2') {
routes = route2;
} else {
// If you want to do something else just comment the line below
routes = index;
}
return routes;
};
/* eslint-disable no-new */
new Vue({
el: '#app',
router: router(),
template: '<App/>',
components: { App },
});
希望对大家有帮助!!!
关于subdomain - Vue.js:vue-router 子域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41654181/
我有一个 github 存储库,我想将我的 Hugo 站点添加到其中。从我的存储库中的 docs 文件夹中,我可以运行 github 页面。 因此,我已将hugo配置中的publishDir参数更改为
我正在使用一个名为 express-subdomain 的express.js 包以方便对我设置的定义子域的请求。 据我了解,子域构造函数需要一个快速路由器对象,我从导出的路由器模块传递给它。 我尝试
我有一个网站,但我在使用 .htaccess 时遇到了一些实际问题...我试了 6 个小时来解决它..我希望有人能帮助我。我刚刚添加了一个子域,包括。 SSL... 问题:1.) 对于需要以下内容的主
我有一些用户尝试访问注册为 subdomain.example.com 且 www.subdomain.example.com 的网站。 是否可以添加某种 .htaccess 规则来将使用 www.s
浏览器是当前的 Chrome 或 FF。在服务器 apache 2.2ish 上。 我启用了许多 SNI 站点 - 虚拟主机 *.443 等。所有单独的配置文件。一切正常。 如果我在浏览器中导航到这些
是否可以使用 .htaccess 重写规则将子子域重定向到子域,并将子子域作为新文件夹? 例如...当我访问 2013.archive.example.com 时,我希望最终到达 archive.ex
我正在使用设计作为我的身份验证系统。我想 使用用户名和子域验证用户。 似乎设计需要用户名和子域字段 同一张 table ,这不是我的情况。 我在公司表中有子域字段,而用户名和密码在 用户帐户表。 并且
示例:hello+all.domain.com 适用于 chrome/firefox。它不适用于 ie/safari。 我想这没有解决方法,对吧?谢谢 我补充说使用 urlencode “有效”:一个
我最初计划将网络上的本地计算机用作开发服务器。 然后我有了使用子域的想法。 因此,如果站点位于www.example.com,则可以在dev.example.com进行开发。 如果这样做,我将知道整个
我知道以前有过一些关于这方面的讨论,但我已经尝试了所有建议的(我能找到的),到目前为止没有任何东西对我有用...... 考虑到这一点,这就是我想要做的: 首先,我想允许用户发布页面并给他们每个他们选择
您可以在子域中使用哪些字符? 示例:对于 someSub.example.com 的 someSub 部分。 我知道您可以使用字母、数字和连字符,但是其他字符呢?可以使用_(下划线)吗? 最佳答案 字
当新用户注册时,许多网站都会创建一个新域,例如 newuser.example.com这是否意味着他们为每个用户都有单独的目录,并将代码库复制到新创建的目录中并创建子域?最好的方法是什么? 最佳答案
谁能告诉我如何从 Google 索引中删除链接到主域的子域。 假设我的域名是 www.myweb.com,我的子域名是 cdn.myweb.com。现在,子域的文档根与主域相同。所以我无法使用 rob
我打算创建一个网站, 我的根域 www.example.com 有一个索引页面,它可以让用户选择 3 个网站 即political.example.com、games.example.com、news
如果这是一个愚蠢的问题,我深表歉意,但我是 Plesk 的新手(以及一般的虚拟服务器)。我有一台运行 Centos 和 Plesk 12 的服务器,我的域和网站运行良好。目前我还有一个 Dreamfa
我需要为子域配置 SPF 记录。 主域的 DNS(我使用 Google Mail): IN MX 1 aspmx.l.google.com. IN MX 10 aspmx3.googlemail
有没有办法动态创建一种介于我的网站域和 .com 之间的子域? 例如,www.onlinevet.com 会是这样的: www.onlinevet.dog.com www.onlinevet.cat.
我有一个使用不同语言的网站 (http://www.boletus-app.com)。每种语言都显示在不同的子域中(http://en.boletus-app.com、http://es.boletu
让我们考虑使用 OOP。 子域是一个类吗?限界上下文是一组一起用于唯一目的(理想情况下)的类吗?子域可以包含一组类吗?如果是,那么 Bounded Context 有什么区别? 例如,我们有一个域:O
一个电子邮件地址可以有多少个子域? 例如:something@something.co.uk.uk像那样.... 最佳答案 没有任何基于子域数量的限制。 RFC821中的电子邮件地址部分长度有限制 u
我是一名优秀的程序员,十分优秀!