Skip to content

ECMAScript block scoped

ythy edited this page Aug 28, 2017 · 1 revision

switch

switch (elem.method) {
  case 'case1':
    let tempData:LBSearchAreaResultInfo[] = elem.data || [];
    break;
  case 'case2':
    let tempData = 2;
    break;
  default:
    break;
}

以上 报错 Cannot redeclare block-scoped variable 'tempData'
Duplicate declaration "tempData"

Clone this wiki locally