https://teratail.com/questions/130729
↑昨日、vue単一ファイルコンポーネントでjqueryが使えず質問しました
原因は
import { $ } from "jquery"
という書き方で、正しくは
import $ from "jquery" か、
import jQuery from "jquery"
と書くべきだったみたいです
しかし、
import { Component, Vue } from 'vue-property-decorator'
このようにimportしている箇所もあります
node_modulesでjquery.jsとvue-property-decorator.jsをみてみました
vue-property-decorator.jsの方では、
たくさんの関数が 'export function "関数名" () {}'といった形で宣言されてました
import { Component, Vue } from 'vue-property-decorator'
はモジュールの中で{}内の特定の関数をimportするみたいな感じでしょうか
jquery.jsは、冒頭部分のみですが、
javascript
1/*! 2 * jQuery JavaScript Library v3.3.1 3 * https://jquery.com/ 4 * 5 * Includes Sizzle.js 6 * https://sizzlejs.com/ 7 * 8 * Copyright JS Foundation and other contributors 9 * Released under the MIT license 10 * https://jquery.org/license 11 * 12 * Date: 2018-01-20T17:24Z 13 */ 14( function( global, factory ) { 15 16 "use strict"; 17 18 if ( typeof module === "object" && typeof module.exports === "object" ) { 19 20 // For CommonJS and CommonJS-like environments where a proper `window` 21 // is present, execute the factory and get jQuery. 22 // For environments that do not have a `window` with a `document` 23 // (such as Node.js), expose a factory as module.exports. 24 // This accentuates the need for the creation of a real `window`. 25 // e.g. var jQuery = require("jquery")(window); 26 // See ticket #14549 for more info. 27 module.exports = global.document ? 28 factory( global, true ) : 29 function( w ) { 30 if ( !w.document ) { 31 throw new Error( "jQuery requires a window with a document" ); 32 } 33 return factory( w ); 34 }; 35 } else { 36 factory( global ); 37 } 38 39...............
このようになってました
jqueryはどういった仕組みでimportされているのでしょうか

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/06/15 02:50 編集