data: {
componentName: ""
}
async getPage () {
const response = await Page.getPage()
this.componentName = ...
}
<component :is="componentName"></component>
v-bind:is
должно быть:the name of a registered component, or
a component’s options object
Vue.component("parent", {
template:`
<div>
<menu-avtr @change-tab="onChangeTab"></menu-avtr>
<component :is="componentName"></component>
</div>
`,
data: () => ({
componentName: "form-inp",
}),
methods: {
onChangeTab(name) {
this.componentName = name;
},
},
});
Vue.component("menu-avtr", {
data: function() {
return {
punktsMenuAvtr: [ {text: 'Вход', tabs: "inp"}, {text: 'Регистрация', tabs: "reg"} ],
currentTab: "inp"
}
},
template: '<menu><li v-for="punkt in punktsMenuAvtr" @click="setTab(punkt.tabs)" v-bind:data-active=" currentTab === punkt.tabs ? true : false ">{{ punkt.text }}</li></menu>',
methods: {
setTab(tab) {
this.currentTab = tab;
this.$emit("change-tab", `form-${tab}`)
},
},
});
let url = "your/api/endpoint";
let limit = 1000; //chunk size per 1 request
let resultData = [];
function loadChunk(from) {
ajax(`${url}?limit=${limit}&from=${from}`, function success(chunkOfData) {
resultData.push(chunkOfData);
if(chunkOfData.length == limit) loadChunk(resultData.length);
})
}
loadChunk(0);
// js
let filterButtons = document.querySelectorAll(".portfolio__gallery-filters a")
filterButtons.forEach(button => {
button.addEventListener("click", function() {
alert(this.getAttribute("href"))
})
})
// jquery
$(".portfolio__gallery-filters a").click(function(e) {
e.preventDefault();
let href = $(this).attr("href");
alert(href);
})
Причина номер раз - козлиные имена переменных, свойств объектов и т.д.
pr_title
? taskname
? showPro
?async (req, res) => {
...
try {
let article = await newArticle.save();
let section = await Section.findOneAndUpdate({ _id: article.section }, {$push: {"articles": article._id}}, {new: true});
if (section === null) return res.json({ message: 'No sections found' });
res.status(201).json({
status: 'OK',
article
});
}
catch(e) {
console.log(e);
next(e);
}
axios.interceptors.request.use(function (config) {
const userToken = localStorage.getItem('user-token');
if(userToken) config.headers["Authorization"] = `JWT ${userToken}`;
return config;
});
<div id="wrap">
<header></header>
<main></main>
<footer></footer>
</div>
html, body {margin: 0}
#wrap {
border: 2px solid #000;
display: flex;
flex-flow: column nowrap;
width: 100vw;
height: 100vh;
}
header {
flex: 0 0 100px;
background: green;
}
footer {
flex: 0 0 150px;
background: blue;
}
main {
flex: 1 1 auto;
background: yellow;
}