ES6-Javascript-未定义Jquery外部

时间:2019-06-11 10:07:39

标签: javascript jquery ecmascript-6 babel yarnpkg

我有一些文件 app.js

import $ from 'jquery';
// export for others scripts to use
window.$ = window.jQuery = $;
import personnal from './assets/js/personnal';
import {cube,machin} from './assets/js/exporting';


$( document ).ready(function() {
    $("div#testok").css({"border":"5px solid black"});

});

在app.js文件jquery中有效,但在我的自定义文件“ personnal.js”中jquery未定义

$( document ).ready(function() {
    console.log($('div#testok'));

});
console.log('loading personnal');

我用纱

{
  "name": "yarnes6",
  "version": "1.0.0",
  "main": "app.js",
  "license": "MIT",
  "browserify": {
    "transform": [
      [
        "babelify",
        {
          "presets": [
            "es2015"
          ]
        }
      ]
    ]
  },
  "scripts": {
    "build": "browserify app.js -o dist/bundle.js",
    "watch": "watchify app.js -o dist/bundle.js -v"
  },
  "dependencies": {
    "browserify": "^16.2.3",
    "jquery": "^3.4.1",
    "reading-time": "^1.2.0",
    "watchify": "^3.11.1"
  },
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-preset-es2015": "^6.24.1",
    "babelify": "^8"
  }
}

无法在我的个人文件上直接使用jquery吗?方法是什么?

0 个答案:

没有答案