binance-fiat-widget
-
You are not on any trade or economic sanctions lists, such as the UN Security Council Sanctions list, designated as a “Specially Designated National” by OFAC (Office of Foreign Assets Control of the U.S. Treasury Department) or placed on the U.S. Commerce Department’s “Denied Persons List”.
-
You are not providing any restricted/prohibited business that could constitute illegal, unlawful activities
Install By HTML CODE in 5 minutes
-
you can get the refId from Binance Referral Program | Binance.com
-
add these codes to your website, and replace your refId
<script src="https://public.bnbstatic.com/static/js/ocbs/binance-fiat-widget.js"></script>
<div id="widget"></div>
<script>
window.onload = function () {
var t = document.querySelector('#widget')
window.binanceFiatWidget.Widget(t, {
urlParmas: {
ref: 'your refId'
}
})
}
</script>
finally
, check the Jump link has the params ref
, like this: https://www.binance.com/cn/buy-sell-crypto?fiat=USD&crypto=BTC&amount=1000&ref=xxxxxx
install
npm install binance-fiat-widget
// or cdn
<script src="https://public.bnbstatic.com/static/js/ocbs/binance-fiat-widget.js"></script>
used
<div id="widget"></div>
import {Widget} from 'binance-fiat-widget'
const options = {
locale: 'en',
width: 200,
theme: 'dark',
urlParmas: {
ref: '',
utm_source: ''
}
}
Widget('#widget', options)
-
react
import {Widget, unloadWidget} from 'binance-fiat-widget'
const app = () => {
const t = useRef<HTMLDivElement>(null)
useEffect(() => {
if (t) {
Widget(t)
}
return () => unloadWidget()
}, [])
return (<div id="#test" ref={r}></div>)
}
Parameters
-
el: selector
or DOM element
-
options.locale: string
i18n
, nullable
, default: 'en'
opts: 'en'|'cn'|'tw'|'kr'|'ru'|'vn'|'it'|'es'|'de'|'fr'
, unsupported locale will fallback to english
-
options.width: number
width
, nullable
,
if width is not set, default is el.offsetWidth
range: 200
- 500
-
options.theme: string
theme
, nullable
, default: 'light'
opts: 'light' | 'dark'
-
options.urlParmas
-
options.api_host: string
overlay getCoinListApi
, nullable
-
options.skeletonScreen: boolean
nullable
, default true
, show a placeholder widget
API
-
setXXX
setXXX
is the function to change Widget's characters, you can use it by chaining
likes jquery
, and you need to use render
to render it
const w = widget(container, opt)
w.setTheme('dark').setLocale('cn').render()
-
setTheme
change the theme
const w = widget(container, opt)
w.setTheme('dark').render()
-
setLocale
change the locale
const w = widget(container, opt)
w.setLocale('cn').render()
-
render
render the widget (after .setXXX()
is necessary)
const w = widget(container, opt)
w.setTheme('dark').render()
render will fetch api, so render
return a Promise
const w = widget(container, opt)
w.setTheme('dark').render().then(v => alert('has render'))
-
unloadWidget
remove the widget from page, maybe you will use it in React hooks to replace setXXX()
useEffect(() => {
if (t?.current) {
w = Widget(t.current, {
theme: theme
})
}
return () => unloadWidget()
}, [theme])