# Install
# NPM
BetterScroll is hosted on NPM and executed with the following command:
npm install @better-scroll/core --save
// or
yarn add @better-scroll/core
The next step is to use it in the code. webpack (opens new window) and other build tools support the introduction of code from node_modules
:
import BScroll from '@better-scroll/core'
If it is the syntax of commonjs, as follows:
var BScroll = require('@better-scroll/scroll')
# Script
BetterScroll also supports direct loading with script, which loads a BScroll object on the window after loading.
<script src="https://unpkg.com/@better-scroll/core@latest/dist/core.js"></script>
<!-- minify -->
<script src="https://unpkg.com/@better-scroll/core@latest/dist/core.min.js"></script>
let wrapper = document.getElementById("wrapper")
let bs = new BScroll(wrapper, {})
# BetterScroll with all plugins
npm install better-scroll --save
// or
yarn add better-scroll
import BetterScroll from 'better-scroll'
let bs = new BetterScroll('.wrapper', {})
Use script.
<script src="https://unpkg.com/better-scroll@latest/dist/better-scroll.js"></script>
<!-- minify -->
<script src="https://unpkg.com/better-scroll@latest/dist/better-scroll.min.js"></script>
let bs = BetterScroll.createBScroll('.wrapper', {})