2
在句法上,我如何使用do expressions编写switch语句?如何使用do-syntax编写switch语句?
例如这样的:
<div>
{do{
switch(foo) {
case 'a':
<Bar/>
case 'b':
<Baz/>
}
}}
</div>
出来作为
'use strict';
React.createElement(
'div',
null,
function() {
switch (foo) {
case 'a':
React.createElement(Bar, null);
case 'b':
React.createElement(Baz, null);
}
}()
);
注意在输出缺乏return
秒 - 也就是说,它是无用的。巴贝尔不会让我增加回报来源。是否可以在do
内部使用switch
?
这看起来像在巴别塔的错误。 –
你期望得到什么回报?从哪里返回?什么?你想解决的实际问题是什么? –
'switch'没有返回值,所以'do'没有任何返回值。它看起来像你试图使用'switch'类似于三元操作符,但它不会那样工作。 – sbking