🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
数组可以使用固定的长度匹配: > Arrays can be matched on fixed length: ~~~ var myArray = [1, 6]; var match = switch(myArray) { case [2, _]: "0"; case [_, 6]: "1"; case []: "2"; case [_, _, _]: "3"; case _: "4"; } trace(match); // 1 ~~~ 这会输出1,因为 array[1]匹配6,array[0]允许是任何内容。 > This will trace 1 because array[1] matches 6, and array[0] is allowed to be anything.