vue.js - Vue baseUrl set in vue-router base
问题描述
If I use a baseUrl in vue.config.js eg. '/directory1' i also must have base: '/directory1' when setting up vue-router otherwise it will route to '/'.
I want to be able to reference baseUrl in my vue app so I can have base: baseUrl in my vue router setup, is this possible?
解决方案
vue.config.js
只是一个导出的对象。在自己的代码中导入这个对象来读取baseUrl应该没有问题:
import { baseUrl } from './vue.config.js'
console.log(baseUrl);
推荐阅读
- android - 为 Room 实现创建新 ViewModel 时类型不匹配 - kotlinx.coroutines 自 1.3 起已过时
- ruby-on-rails - 在 Rails 中渲染两个 JSON 项
- python - 如何从 func1 中获取 var1 并在 func2 中使用它而不在 func1 中运行两次
- c - 使用 mmap 读取/写入文件时如何解析 ENODEV
- python - ',' 在这个切片操作中做了什么 - [:,::-1]
- c# - 在可视化树中添加和删除用户控件会引发 Unloaded 事件,但不会引发 Loaded 事件
- swift - 是否有更可定制的方式来创建嵌入式超链接?
- sql - 个人和团体帐户的数据库模式(如 Facebook 用户和页面)
- javascript - window.move 在负方向问题
- c++ - 如何降低高分辨率(10 微秒)精确计时器的 CPU 使用率?