如何获取into 方法的quantity局部变量值并将其分配给其中的局部变量?valueChangedfunctionName1functionName2
var functionName1 = function() {
$newCheckoutNumberPicker.WanSpinner({
maxValue: 99,
minValue: 0,
valueChanged: function(ele, val) {
var quantity = val
}
});
}
var functionName2 = function() {
var test1 = "";
functionName1();
}
Run Code Online (Sandbox Code Playgroud)
你可以使用回调函数:
var functionName1 = function(callback) {
$newCheckoutNumberPicker.WanSpinner({
maxValue: 99,
minValue: 0,
valueChanged: function(ele, val) {
callback(val)
}
});
}
var functionName2 = function() {
var test1 = "";
functionName1(function (quantity) {
// ...
});
}
Run Code Online (Sandbox Code Playgroud)