1.新建vue文件
src/view/standard/Global.vue
<script>
/**
*
* @title 公共常量
* @Description 公共常量
* 1.定義: const 常量名 = '常量值';
* 2.對外暴露該定義: export default 中添加定義常量;
* 3.引用: this.GLOBAL.常量名
* @Author chenglf
* @Date 2020/4/21
* @params
* @return
**/
const TEXT_SEARCH = '查詢';
const TEXT_ADD = '新增';
const TEXT_VIEW = '查看';
const TEXT_EDIT = '編輯';
const TEXT_DELETE = '刪除';
/*
* @title 彈窗按鈕
* @Author chenglf
**/
const BTN_CLOSE = '關閉';
const BTN_CANCEL = '取消';
const BTN_OK = '確定';
/**
* 提示信息
* @Author chenglf
* @type {string}
*/
const MSG_TITLE_TIPS = '溫馨提示'
const MSG_FAILED_DEL = '刪除失敗';
const MSG_FAILED_SAVE = '保存失敗';
export default
{
TEXT_SEARCH,
TEXT_ADD,//新增
TEXT_VIEW,//查看
TEXT_EDIT,//編輯
TEXT_DELETE,
BTN_CLOSE,
BTN_CANCEL,
BTN_OK,
MSG_FAILED_DEL,//刪除
MSG_TITLE_TIPS,
MSG_FAILED_SAVE,
}
</script>
2.main.js中添加
// chenlf 全局常量
import global_ from './view/standard/Global'//引用文件
Vue.prototype.GLOBAL = global_ //掛載到Vue實例上面
3.使用
this.GLOBAL.DAILOG_TITLE_ADD;