Comments (3)
package.jsonのdependenciesにあるパッケージは以下の方法でインポートする。
import $ from 'jquery';
import picturefill from 'picturefill';
自作ファイルは以下のように相対パスでインポートする(関数の呼び出しは不要)。
import jsAlignHeight from './namespace/js/alignHeight.js';
from website-template.
import文はどちらが適切か?
import { export } from "module-name";
import "module-name";
jQueryはexport
に$
を指定しないと、そのファイルでjQueryが使えない。
export
は名前空間のような役割になっている?ので、指定したほうが無難?
from website-template.
jQueryプラグインの修正
import $ from 'jquery';
import 'jquery-match-height';
export default function jsAlignHeight () {
$('.js-alignHeight').matchHeight();
};
import SmoothScroll from 'smooth-scroll';
export default function jsSmoothScroll () {
const jsSmoothScroll = new SmoothScroll('.js-smoothScroll', {
ignore: '.js-smoothScroll-ignore', // Selector for links to ignore (must be a valid CSS selector)
header: '.js-smoothScroll-header', // Selector for fixed headers (must be a valid CSS selector)
topOnEmptyHash: true, // Scroll to the top of the page for links with href="#"
speed: 500, // Integer. How fast to complete the scroll in milliseconds
clip: true, // If true, adjust scroll distance to prevent abrupt stops near the bottom of the page
easing: 'easeInOutCubic' // Easing pattern to use
});
};
import jsAlignHeight from './namespace/js/alignHeight';
import jsSmoothScroll from './namespace/js/smoothScroll';
jsAlignHeight();
jsSmoothScroll();
from website-template.
Related Issues (20)
- Add: メディアクエリを管理するJSを追加する HOT 1
- Fix: CSSが圧縮されないのを修正する
- Fix: element-closestの記述方法を変更する HOT 1
- Fix: ロード時のスムーススクロールのタイミングを変更する
- Add: stylelintに&で結合セレクターを生成しないオプションを追加する
- Add: API通信の雛形を作成する HOT 1
- Improve: BlogList.vueのリファクタリング
- JSとVue.jsの構成を変更する
- Improve: Storage.jsとHistory.jsをリファクタリング
- Add: Autoprefixerオプションにgridを追加 HOT 2
- Improve: l-Flexをリファクタリング
- Improve: sw-Buttonのスタイルを見直す HOT 1
- Improve: スムーススクロール後にフォーカスを移動する
- Improve: input[type="text"]のplaceholderがズレないようにする
- Add: Vuex使用時のESLintエラーを解消する
- Fix: jsSmoothScroll.jsの対象セレクタから`href="#"`を除去する
- Improve: スムーススクロールの設定を統一する
- Add: VuexがIEで動くようにes6-promiseをインポートする
- Fix: data-whatinputからdata-whatintentに変更する
- Add: npmパッケージをできる範囲でアップデートする HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from website-template.