Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed May 23, 2020
1 parent fa3ad4e commit 1b20567
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
11 changes: 6 additions & 5 deletions dist/vxe-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,22 @@
function VXEUtils(app, XEUtils, options) {
var isV3 = typeof app !== 'function';
var mounts = options && options.mounts && options.mounts.length ? options.mounts.join(';') : [];
var variate = '$utils';

var setMount = function setMount(name, obj) {
var setMount = function setMount(name) {
if (mounts.indexOf(name) > -1) {
if (isV3) {
app.config.globalProperties['$' + name] = obj || XEUtils[name];
app.config.globalProperties['$' + name] = XEUtils[name];
} else {
app.prototype['$' + name] = obj || XEUtils[name];
app.prototype['$' + name] = XEUtils[name];
}
}
};

if (isV3) {
setMount('utils', XEUtils);
app.config.globalProperties[variate] = XEUtils[name];
} else {
Object.defineProperty(app.prototype, '$utils', {
Object.defineProperty(app.prototype, variate, {
get: function get() {
XEUtils.$context = this;
return XEUtils;
Expand Down
2 changes: 1 addition & 1 deletion dist/vxe-utils.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
function VXEUtils (app, XEUtils, options) {
var isV3 = typeof app !== 'function'
var mounts = options && options.mounts && options.mounts.length ? options.mounts.join(';') : []
var setMount = function (name, obj) {
var variate = '$utils'
var setMount = function (name) {
if (mounts.indexOf(name) > -1) {
if (isV3) {
app.config.globalProperties['$' + name] = obj || XEUtils[name]
app.config.globalProperties['$' + name] = XEUtils[name]
} else {
app.prototype['$' + name] = obj || XEUtils[name]
app.prototype['$' + name] = XEUtils[name]
}
}
}
if (isV3) {
setMount('utils', XEUtils)
app.config.globalProperties[variate] = XEUtils[name]
} else {
Object.defineProperty(app.prototype, '$utils', {
Object.defineProperty(app.prototype, variate, {
get: function () {
XEUtils.$context = this
return XEUtils
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-utils",
"version": "1.9.1",
"version": "1.9.2",
"description": "用于 Vue 全局安装 xe-utils",
"main": "dist/vxe-utils.common.js",
"unpkg": "dist/vxe-utils.js",
Expand Down

0 comments on commit 1b20567

Please sign in to comment.