首页 > 解决方案 > 在 Nuxt 中存储常量的最佳方法是什么?

问题描述

我有一个 nuxt 项目(vuejs),我想知道如何在我的项目中存储常量?(大约 50 个常数)。

谢谢您的答复。卡布梅

标签: vue.jsconstantsnuxt.js

解决方案


我可以创建一个 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';

谢谢


推荐阅读