12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- import 'vant/es/notify/style';
- import { Toast, showLoadingToast, showSuccessToast, showFailToast, closeToast } from "vant";
- /**
- * 文字:Toast 提示组件
- * @param {String} text
- * @param {Number} duration
- */
- const toastText = (text = '', duration = 2000) => {
- showToast({
- message: text,
- duration: duration,
- forbidClick: true
- });
- }
- /**
- * 加载:Toast 提示组件
- * @param {String} text
- * @param {Number} duration
- */
- const toastLoading = (text = '', duration = 2000) => {
- showLoadingToast({
- message: text,
- duration: duration,
- forbidClick: true
- });
- }
- /**
- * 成功过:Toast 提示组件
- * @param {String} text
- * @param {Number} duration
- */
- const toastSuccess = (text = '', duration = 2000) => {
- showSuccessToast({
- message: text,
- duration: duration,
- forbidClick: true
- });
- }
- /**
- * 失败:Toast 提示组件
- * @param {String} text
- * @param {Number} duration
- */
- const toastFail = (text = '', duration = 2000) => {
- showFailToast({
- message: text,
- duration: duration,
- forbidClick: true
- });
- }
- /**
- * 清除所有的 Toast 提示
- */
- const clearToast = () => {
- closeToast(false)
- }
- const useShowToast = () => {
- return {
- toastText,
- toastLoading,
- toastSuccess,
- toastFail,
- clearToast
- }
- }
- export default useShowToast;
|