这个问题仔细检查了一下代码引入,是没有问题的,
根本原因是在页面上忘了加<van-toast id="van-toast" />
具体引入代码如下:
app.json
"usingComponents": {
"tab-bar": "custom-tab-bar/index",
"van-icon": "@vant/weapp/icon/index",
"van-tab": "@vant/weapp/tab/index",
"van-toast": "@vant/weapp/toast/index", // 这一个哦,其他的是其他组件
"van-field": "@vant/weapp/field/index",
"van-popup": "@vant/weapp/popup/index",
"van-collapse": "@vant/weapp/collapse/index",
"van-collapse-item": "@vant/weapp/collapse-item/index",
"van-tabs": "@vant/weapp/tabs/index",
"van-picker": "@vant/weapp/picker/index",
"van-cell": "@vant/weapp/cell/index",
"van-cell-group": "@vant/weapp/cell-group/index",
"van-calendar": "@vant/weapp/calendar/index",
"van-button": "@vant/weapp/button/index",
"van-datetime-picker": "@vant/weapp/datetime-picker/index"
},
HTML
<van-toast id="van-toast" />
JS:
import Toast from '../../miniprogram_npm/@vant/weapp/toast/toast.js';
Toast('我是提示文案,建议不超过十五字~');