移動端微信小程序開發學習報錯記錄--toast.js:41 未找到 van-toast 節點,請確認 selector 及 context 是否正確


這個問題仔細檢查了一下代碼引入,是沒有問題的,

根本原因是在頁面上忘了加<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('我是提示文案,建議不超過十五字~');

在這里插入圖片描述


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM