1

我正在使用 symfony 4.2;我也在使用 webpack 和 yarn 来管理我的资产。
我已经使用以下方法添加了包:

yarn add pnotify

我可以看到node_modules. 我需要 css 和 js 文件:

require('pnotify/dist/PNotifyBrightTheme.css');
require('pnotify');

当我运行此命令时,我收到以下错误:

yarn run encore dev

无法解决 app.js 中的 pnotify

如果我将其更改require为此它会成功构建:

require('pnotify/dist/umd/PNotify');

当我尝试用这样的树枝进行测试时,出现以下错误:

<script type="text/javascript">
  $(document).ready(function() {
    (new PNotify({
      title: 'Regular Notice,
      text: 'Check me out! I\'m a notice.',
      type: 'info',
      styling: 'bootstrap3'
    }));
  });
</script> 
> vendor.js:7803 Uncaught ReferenceError: PNotify is not defined
at HTMLDocument.<anonymous> (create:513)
at mightThrow (vendor.js:7510)
at process (vendor.js:7578)
4

1 回答 1

1

看来正确的做法是这样的:

import PNotify from 'pnotify/dist/es/PNotify';
import PNotifyButtons from 'pnotify/dist/es/PNotifyButtons';

按照这个链接

于 2019-09-25T11:42:55.587 回答