找不到名称“Handlebars”

问题描述 投票:0回答:1

我正在尝试在 Typescript 中使用把手。我收到以下错误

/// <reference path="../../../jquery.d.ts" />
/// <reference path="../../../require.d.ts" />

我无法弄清楚如何引用车把定义文件以使其正常工作

private populateData(data){
    var base=this;
    var jsData=document.getElementById('header').innerHTML;
    var getdata=document.getElementById('header').innerHTML;
    var compiledData = Handlebars.compile(getdata);
    $('.displayData').html(compiledData(data));
}

错误:dev/include/ts/test.ts(43,28):错误TS2304:找不到名称“Handlebars”

同时包含@types/handlebar by

import * as Handlebars from 'handlebars';

出现以下错误

>> handlebars.d.ts(21,31): error TS1005: ',' expected.
>> handlebars.d.ts(23,32): error TS1005: ',' expected.
>> handlebars.d.ts(98,40): error TS1005: ',' expected.
javascript typescript handlebars.js
1个回答
0
投票

将其添加到脚本顶部:

declare const Handlebars: any;
© www.soinside.com 2019 - 2024. All rights reserved.