0
YUI().use('dd-constrain', 'dd-proxy', 'dd-drop', function(Y) {
var lis = Y.Node.all('#listContainer ul li');//Get a NodeList of all li
lis.each(function(v,k) {
var dd = new Y.DD.Drag({
node:v,
//Make it Drop target and pass this config to the Drop constructor
//Not sure what this actually means
target: {
padding: '0 0 0 20'
}
}).plug(Y.Plugin.DDProxy, {
//Don't move the node at the end of the drag
moveOnEnd:false
}).plug(Y.Plugin.DDConstrained, {
//Keep it inside the #listContainer node
constrain2node: '#listContainer'
});
});
参数v和k在函数中指的是什么?看起来v是节点,这可能是有道理的,但那么k是什么?此外,“目标:”部分是做什么的?这个YUI函数中的参数v和k是指什么?
'value'的内容/值和'key',共同对数组/对象 – helion3
是迭代的时候,但我想知道什么是价值,关键是在YUI节点中 – michaelAdam
您正在迭代'lis.each',它是'#listContainer'中的列表项元素。所以'value'就是'li','key'可能是一个数字索引,'0,1,2'等。 – helion3