mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-10-24 01:49:10 +08:00
*
This commit is contained in:
36
static/element-ui/lib/mixins/emitter.js
Normal file
36
static/element-ui/lib/mixins/emitter.js
Normal file
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
function _broadcast(componentName, eventName, params) {
|
||||
this.$children.forEach(function (child) {
|
||||
var name = child.$options.componentName;
|
||||
|
||||
if (name === componentName) {
|
||||
child.$emit.apply(child, [eventName].concat(params));
|
||||
} else {
|
||||
_broadcast.apply(child, [componentName, eventName].concat([params]));
|
||||
}
|
||||
});
|
||||
}
|
||||
exports.default = {
|
||||
methods: {
|
||||
dispatch: function dispatch(componentName, eventName, params) {
|
||||
var parent = this.$parent || this.$root;
|
||||
var name = parent.$options.componentName;
|
||||
|
||||
while (parent && (!name || name !== componentName)) {
|
||||
parent = parent.$parent;
|
||||
|
||||
if (parent) {
|
||||
name = parent.$options.componentName;
|
||||
}
|
||||
}
|
||||
if (parent) {
|
||||
parent.$emit.apply(parent, [eventName].concat(params));
|
||||
}
|
||||
},
|
||||
broadcast: function broadcast(componentName, eventName, params) {
|
||||
_broadcast.call(this, componentName, eventName, params);
|
||||
}
|
||||
}
|
||||
};
|
||||
17
static/element-ui/lib/mixins/locale.js
Normal file
17
static/element-ui/lib/mixins/locale.js
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
|
||||
var _locale = require('element-ui/lib/locale');
|
||||
|
||||
exports.default = {
|
||||
methods: {
|
||||
t: function t() {
|
||||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return _locale.t.apply(this, args);
|
||||
}
|
||||
}
|
||||
};
|
||||
62
static/element-ui/lib/mixins/migrating.js
Normal file
62
static/element-ui/lib/mixins/migrating.js
Normal file
@@ -0,0 +1,62 @@
|
||||
'use strict';
|
||||
|
||||
exports.__esModule = true;
|
||||
/**
|
||||
* Show migrating guide in browser console.
|
||||
*
|
||||
* Usage:
|
||||
* import Migrating from 'element-ui/src/mixins/migrating';
|
||||
*
|
||||
* mixins: [Migrating]
|
||||
*
|
||||
* add getMigratingConfig method for your component.
|
||||
* getMigratingConfig() {
|
||||
* return {
|
||||
* props: {
|
||||
* 'allow-no-selection': 'allow-no-selection is removed.',
|
||||
* 'selection-mode': 'selection-mode is removed.'
|
||||
* },
|
||||
* events: {
|
||||
* selectionchange: 'selectionchange is renamed to selection-change.'
|
||||
* }
|
||||
* };
|
||||
* },
|
||||
*/
|
||||
exports.default = {
|
||||
mounted: function mounted() {
|
||||
if (process.env.NODE_ENV === 'production') return;
|
||||
if (!this.$vnode) return;
|
||||
|
||||
var _getMigratingConfig = this.getMigratingConfig(),
|
||||
props = _getMigratingConfig.props,
|
||||
events = _getMigratingConfig.events;
|
||||
|
||||
var _$vnode = this.$vnode,
|
||||
data = _$vnode.data,
|
||||
componentOptions = _$vnode.componentOptions;
|
||||
|
||||
var definedProps = data.attrs || {};
|
||||
var definedEvents = componentOptions.listeners || {};
|
||||
|
||||
for (var propName in definedProps) {
|
||||
if (definedProps.hasOwnProperty(propName) && props[propName]) {
|
||||
console.warn('[Element Migrating][Attribute]: ' + props[propName]);
|
||||
}
|
||||
}
|
||||
|
||||
for (var eventName in definedEvents) {
|
||||
if (definedEvents.hasOwnProperty(eventName) && events[eventName]) {
|
||||
console.warn('[Element Migrating][Event]: ' + events[eventName]);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
getMigratingConfig: function getMigratingConfig() {
|
||||
return {
|
||||
props: {},
|
||||
events: {}
|
||||
};
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user