代码之家  ›  专栏  ›  技术社区  ›  monstertjie_za

将参数传递给环境文件中的匿名函数

  •  1
  • monstertjie_za  · 技术社区  · 7 年前

    我试图将参数传递给环境文件中的匿名函数,wihch应该替换 ${} 传入了参数,但它没有按预期工作,因此我一定是做错了什么。

    这是我的档案:

    export const environment = {
      production: false,
      endpoints: {
        customer: {
          test: (searchTerm: string) => 'http://localhost:7071/api/Customer/SearchCustomerBySearchTerm/${searchTerm}',
        },
      }
    };
    

    const url = environment.endpoints.customer.test('aaa');
    

    ${searchTerm} ,我实际上通过了“aaa”。

    我错过了什么?

    1 回复  |  直到 7 年前
        1
  •  1
  •   Henry    7 年前

    test: (searchTerm: string) => `http://localhost:7071/api/Customer/SearchCustomerBySearchTerm/${searchTerm}`
    
    推荐文章