Principle analysis of passing parameters when jquery references methods
- 2020-03-30 04:04:42
- OfStack
Often go to the Internet to download Daniel write js plug-in. All you need to do is to reference js and set a variable at a time, but you never understand the principle (mainly because the code is too concise -, -).
This time you figured out how to pass and set multiple (many) parameters.
Function lunbo(){};
When calling or setting:
lunbo({
speed:200,
wrapper:'#id',
ease:'easing'
})
Then, when obtained within the method:
function lunbo(options){
var set=$.extend({},options);
var _speed=set.speed;
var _wrapper=set.wrapper;
var _ease=set.ease;
}
In addition, when there is no way, you can set global variables flexible use.