有没有办法在结构化后获得论点?
Is there a way to get arguments after distructuring?
我试图从 React 的功能组件内部获取参数列表。
export function SomeFunction ({ first, second third }){
// do something with the arguments
let props = this.arguments;
return <div> hello</div>}
那么在我对它们进行结构化处理后是否可以获取所有参数?
将解构移动到第二行如何:
export function SomeFunction (props) {
const { first, second, third } = props;
//...
}
如果你需要引用整个道具对象,你可以通过 props
。
你很接近,你可以使用函数中的 arguments 值。 arguments
是一个类似数组的对象,并且由于该函数仅使用一个参数,您可以访问第零个元素。
function SomeFunction({ first, second, third }) {
// do something with the arguments
const props = arguments[0];
console.log(props);
return 42;
}
SomeFunction({ first: "1", second: 2, third: "third", fourth: "4th" });
我试图从 React 的功能组件内部获取参数列表。
export function SomeFunction ({ first, second third }){
// do something with the arguments
let props = this.arguments;
return <div> hello</div>}
那么在我对它们进行结构化处理后是否可以获取所有参数?
将解构移动到第二行如何:
export function SomeFunction (props) {
const { first, second, third } = props;
//...
}
如果你需要引用整个道具对象,你可以通过 props
。
你很接近,你可以使用函数中的 arguments 值。 arguments
是一个类似数组的对象,并且由于该函数仅使用一个参数,您可以访问第零个元素。
function SomeFunction({ first, second, third }) {
// do something with the arguments
const props = arguments[0];
console.log(props);
return 42;
}
SomeFunction({ first: "1", second: 2, third: "third", fourth: "4th" });