vue.js - 在 Nuxt 中存储常量的最佳方法是什么?
问题描述
我有一个 nuxt 项目(vuejs),我想知道如何在我的项目中存储常量?(大约 50 个常数)。
谢谢您的答复。卡布梅
解决方案
我可以创建一个 constants.js 文件并
// constants.js
export const CONSTANT_1 = 'CONSTANT_1';
export const CONSTANT_2 = 'CONSTANT_2';
export const CONSTANT_3 = 'CONSTANT_3';
// And call it like this
import { CONSTANT_1 } from 'constants';
谢谢
推荐阅读
- python - 如何从 metrics-server 获取 Pod CPU 和内存使用情况?
- django - Django 和登录“记住我”:如何查看其他代码的状态?
- java - 如何在 Java 中将 sun.nio.fs.ZipPath 转换为 sun.nio.fs.UnixPath?
- java - 在 Hibernate Search 运行时选择分析器
- winforms - 当我从列表视图中拖动项目时,如何在包含列表视图的表单中触发拖动或拖放事件?
- c++ - 在 C++ 中使用 new 分配大于 2GB 的单个对象(在 Windows 上)
- terraform - 如何在 Terraform 中按名称应用我的资源之一?
- airflow - 如何管理气流 dags 之间的 python 包?
- python - 删除 try 和 except 块中的重复项
- javascript - 位于共享文件夹中的 Web 应用程序下载文件