admin管理员组

文章数量:1394089

I've installed the jquery plugin summernote using npm and it's within my node_modules directory.

I'm now trying to utilise the summernote function in much the same way as I was before when I was just loading the scripts within the html.

import { summernote } from 'summernote';

export default function () {
    const summernote = $('.editor');
    summernote.summernote();
}

I can't get past the above code throwing summernote.summernote is not a function

I've installed the jquery plugin summernote using npm and it's within my node_modules directory.

I'm now trying to utilise the summernote function in much the same way as I was before when I was just loading the scripts within the html.

import { summernote } from 'summernote';

export default function () {
    const summernote = $('.editor');
    summernote.summernote();
}

I can't get past the above code throwing summernote.summernote is not a function

Share Improve this question edited Apr 26, 2017 at 17:24 Luke Vincent asked Apr 26, 2017 at 17:13 Luke VincentLuke Vincent 1,3233 gold badges20 silver badges36 bronze badges 5
  • I'm not sure what you're suggesting – Luke Vincent Commented Apr 26, 2017 at 17:21
  • 1 import { summernote } from 'summernote'; declare var $; is not valid syntax – Luke Vincent Commented Apr 26, 2017 at 17:25
  • Which bundler are you using? – Prashant Commented Apr 26, 2017 at 17:27
  • 1 A jQuery plugin that does install a method to the global jQuery prototype would not export anything. Are you sure you did import jQuery and $ refers to jQuery? import $ from 'jquery'; import 'summernote'; should do. – Bergi Commented Apr 26, 2017 at 17:27
  • That seems to have worked although jquery seemed to be working fine. It's only when I tried to access a plugin through a jquery obj would I get an error. – Luke Vincent Commented Apr 26, 2017 at 17:31
Add a ment  | 

1 Answer 1

Reset to default 5

This module doesn't export anything useful (like it should be expected from jQuery plugin package).

Imported summernote isn't used, and unused imported member makes an import a noop.

It should be

import 'summernote';

本文标签: javascriptUtilise jQuery plugin with ES6 importStack Overflow