0
我试图用这段代码将元素放置在随机位置,但它只是将元素放置在我的容器元素的顶部。我究竟做错了什么?将元素放置在随机位置
create: function(){
console.log("cone created");
var el = document.createElement('div');
el.classList.add('cone');
this.container.appendChild(el);
this.el = el;
this.x = Math.random() * canvas.innerWidth + 'px';
this.y = Math.random() * canvas.innerHeight + 'px';
},
实际上用'this.x'和'this.y'做些什么的代码在哪里? –