问题描述
我正在开发一个简单的Web应用程序,并且正在使用两个js库:dat.gui和three.js。
I'm developing an easy web application, and I'm using two js libraries: dat.gui and three.js.
我的问题是下拉列表菜单被锁定。我无法打开它。
My problem is the drop down menu is locked. I can't open it.
// gui initialization (dat.gui)
function initGui() {
var Options = function() {
this.tenda = 'bar';
};
config = new Options();
var gui = new dat.GUI();
var subGui = gui.addFolder('Setting');
subGui.open();
// callbacks
subGui.add( config, 'tenda', ['bar', 'pie', 'area']).
onChange(
function() {
if (config.tenda === 'bar') { ... }
else if (config.tenda === 'pie') { ... }
else if (config.tenda === 'area') { ... }
}
);
};
在网络上阅读,这似乎是一个已知问题,但在某些示例中,我看到了下拉菜单效果很好。我是js的新手,所以我认为也许存在一些范围问题,因此我将初始化过程放在了一个可以正常工作的函数中。但是问题仍然存在。
Reading on the web, it seems to be a known issue, but in some examples, I see the drop down menus working well. I'm new to js, and I thought "maybe there is some scoping issue", so I put the initialization process inside a function that does the work. But the problem remains.
我正在使用Ubuntu / Chrome和Ubuntu / Firefox。您可以在检查整个代码,在此我使用复选框而不是
I'm working on Ubuntu/Chrome and Ubuntu/Firefox. You could check the entire code here, where I use check boxes instead of a drop down menu.
推荐答案
我遇到了同样的问题。在我的代码中,我进行了更改:
I face the same problem. In my code, I have changed:
var controls = new THREE.OrbitControls(camera);
到
var controls = new THREE.OrbitControls(camera, renderer.domElement);
这篇关于下拉菜单不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!