系统js映射不起作用 [英] System js map doesn't work

查看:117
本文介绍了系统js映射不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许我很笨,但是系统js总是给我带来很多痛苦,尽管它是如此的好以至于我不想使用其他任何东西.

Maybe I am dumb but system js always gives so much pain, although its so nice that I don't want to use anything else.

我的系统js配置是这样的:

My system js config is this:

System.config({
        packages: {
            app: {
                format: 'register',
                defaultExtension: 'js'
            },
            primeng:{
                format: 'register',
                defaultExtension: 'js'
            }
        },
        map: {
          primeng: 'node_modules/primeng'
        }
    });

Primeng的导入方式如下:

Primeng is being imported like this:

import {Accordion} from "primeng/primeng";
import {AccordionTab} from "primeng/primeng";

这是一个ts文件,该文件由gulp在js中编译,然后由我的index.html使用.

This is a ts file which gets compiled in js by gulp and then used by my index.html.

但是在我的终端机中出现错误:

But in my terminal I get error:

error TS2307: Cannot find module 'primeng/primeng'

如果有人有任何想法,请解决此问题

If anyone has any idea, please solve this

推荐答案

弄清楚了.

我们必须在组件的.ts文件本身中引用类型定义.因此,在我的组件文件的顶部,我必须编写以下代码:

We have to reference the type definition in the component's .ts file itself. So at the top of my component file I have to write this:

///<reference path="../../node_modules/primeng/components/accordion/accordion.d.ts"/>

这篇关于系统js映射不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆