не корректно работает
data: () => ({
scroll: 0,
}),
computed: {
buttonClass() {
return что-то, зависящее от значения this.scroll;
},
},
created() {
const { body } = document;
const onScroll = () => this.scroll = body.scrollTop;
body.addEventListener('scroll', onScroll);
this.$on('hook:beforeDestroy', () => body.removeEventListener('scroll', onScroll));
},<button :class="buttonClass"></button>uncaught exception: We found an infinite loop in your Pen. We've stopped the Pen from running. Please correct it or contact support@codepen.io.
for(var i = 0; a.length; i++) {
// должно быть
for(var i = 0; i < a.length; i++) { console.log().this – ваш объект, а где становится «вдруг» window:console.log("внутри timeout", this);(callback) => { ... } от обычных function() { ... }this.response = function() { .. тут собственный this.. } Когда передаёте аргументом ..(t.response), он улетает из контекста Window, поэтому в нём this == window. this.response = () => { .. тут this на момент обращения к нему .. }callback() или this.data = "Steve Jobs" ?function test() {
this.data = null;
this.response = function() {
console.log(this, this.data);
}
this.connect = function(callback) {
setTimeout(() => {
this.data = "Steve Jobs";
callback.call(this);
}, 500);
}
}
t = new test();
t.connect(t.response);
const Menu = ({ items }) =>
items instanceof Array && items.length
? <ul>
{items.map(n => (
<li key={n.id}>
<a>{n.title}</a>
<Menu items={n.children} />
</li>
))}
</ul>
: null;
const getNested = (obj, ...keys) => keys
.flat(Infinity)
.flatMap(n => typeof n === 'string' ? n.split('.') : n)
.reduce((p, c) => p?.[c] ?? null, obj);getNested(data, [ 'hosts', 1, null ]) // 3
getNested(data, 'hosts', 0) // {name: 'web1'}
getNested(data, 'hosts.0.name.2') // 'b'
getNested(data, [ 'user', 'xxx' ]) // null
getNested([], 'constructor.prototype', [[['slice']]], ['name.length']) // 5 пошел на курсы Web разработки, курс оказался посредственным, знания давались поверхностные
можно ли достаточно быстро( в пределах полугода) освоить просто верстку и на ней хоть что-то зарабатывать?
как бы вы поступили на моем месте?