ES6导入 - 别名字符串成员?

时间:2015-09-08 04:40:50

标签: javascript import ecmascript-6

我只是仔细检查以下作为ES6导入的语法无效:

import { stream_streamItem_html as StreamItemTemplate } from 'common/template';

我真的更喜欢这样写,而不是像:

foreach (DataGridViewRow row in dataGridView1.Rows)
   {

       if (row.Cells.Count >= 2 && row.Cells[0].Value != null)
       {
           _peixe_list.Add(row.Cells[0].Value.ToString());
           _peso_list.Add(row.Cells[1].Value.ToString());
           _quant_list.Add(row.Cells[2].Value.ToString());
       }

   }

但是看起来字符串即使在别名时也不是有效的成员声明?

2 个答案:

答案 0 :(得分:1)

标准需要IdentifierName而不是StringLiteral:

  

ImportSpecifier:

     

ImportedBinding

     

IdentifierName as ImportedBinding

http://www.ecma-international.org/ecma-262/6.0/#sec-imports

答案 1 :(得分:1)

根据spec,您示例中的stream_streamItem_htmlIdentifierNameIdentifierName根据spec,(引用)"根据默认标识符语法"解释,这意味着不允许使用StringLiterals。

相关问题