import component1 from './component1.vue';
import component2 from './component2.vue';
...
export {component1, component2}
components = {};
fs
.readdirSync(__dirname)
.filter(function(file) {
return (file.indexOf(".") !== 0) && (file !== "index.js");
})
.forEach(function(file) {
components[component.name] = require(path.join(__dirname, file));
});
module.exports = components;
for (var component in components) {
Vue.component(component, components[component]);
}
import {component} from './components/common'
<div @mouseenter="hoverClass='myclass'" @mouseleave="hoverClass=''" :class="hoverClass"></div>
$.fn.serializeObject = function ()
{
var o = {};
var a = this.serializeArray();
$.each(a, function () {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
function sendForm(form, data) {
return new Promise((fulfill, reject) => {
if (!data)
data = $(form).serializeObject();
// console.log(`${form.method} ${form.action}`);
var ajaxSettings = {
method: form.method,
url: form.action,
data: JSON.stringify(data),
// dataType: form.method === 'get' ? 'jsonp' : 'json',
dataType: 'json',
contentType: 'application/json',
processData: false,
xhrFields: {
withCredentials: true
}
};
var ajaxRequest = $.ajax(ajaxSettings);
ajaxRequest.done((data, textStatus) => {
console.log(textStatus);
console.log(JSON.stringify(data, null, 2));
fulfill(data);
});
ajaxRequest.fail((response, textStatus, errorThrown) => {
console.log(textStatus);
console.log(errorThrown);
if (response.status === 401) {
screenLogin();
} else if (response.responseText) {
var data = JSON.parse(response.responseText);
console.log(JSON.stringify(data, null, 2));
} else {
console.log(errorThrown);
}
reject(data);
});
});
}
$('#formLogin').on('submit', (event) => {
sendForm(event.target)
.then(data => {
////
}).catch(error => {
/////
});
return false;
});
sendForm({method: "POST", action: '/templates/'}, {id: form.filter_id}).then(data => {
/////// обработка
});