Snap SVG出现Typescript和Webpack错误“无法读取未定义的属性'on'"; [英] Snap SVG with Typescript and Webpack error "Cannot read property 'on' of undefined"

查看:340
本文介绍了Snap SVG出现Typescript和Webpack错误“无法读取未定义的属性'on'";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用Snap SVG的Angular 4应用,但遇到了webpack问题:无法读取未定义的属性'on'".

I have an Angular 4 app using Snap SVG and I get the dredded webpack problem "Cannot read property 'on' of undefined".

使用snapsvg-cjs似乎是解决此问题的最简单方法,但随后我丢失了所有不错的打字稿类型(在此处回答:

Using snapsvg-cjs seems to be the simplest way to fix this but then I lose all the nice typescript typings (answered here: Typescript library for SVG).

有一些关于使用import-loader的讨论,但是随后我需要一个Web Pack配置,而角度cli可以解决这个问题.加:

There is some talk of using import-loader but then I would need a web pack config and angular cli takes that away. Plus :

import Snap from 'imports-loader?this=>window,fix=>module.exports=0!snapsvg/dist/snap.svg.js';

不会在打字稿中编译.

我对所有这些东西都还很陌生,因此感到有些困惑-我希望我又回到Windows上进行VB6了.... :).任何人都可以澄清吗?

Im pretty new to all this stuff so am feeling somewhat confused - I wish I was back doing VB6 on windows again.... :). Can anyone clarify this ?

谢谢

推荐答案

好的,我知道我现在做了什么.使用snapsvg-cjs即可.我得到打字稿支持.

Ok, I see what I did now. Using snapsvg-cjs just works. I get typescript support.

这篇关于Snap SVG出现Typescript和Webpack错误“无法读取未定义的属性'on'";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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