使用Vant完成通知欄Notify的提示操作
效果:

代碼展示:
<template> <!-- 通知消息提示 --> <div id="notify"> <van-button type="primary" @click="toNotify" class="btn">頂部通知</van-button> </div> </template>
<script>
export default{
data(){
return{
msg:''
}
},
methods:{
toNotify(){
this.$notify({
message:'我是提示的notify',
background:'pink',
duration: 1000
})
}
},
mounted() {
}
}
</script>
<style scoped="scoped">
.btn{
margin-top: 100px;
}
</style>
補充知識:vantweapp引入notify消息提示組件解決importpath/to/@vant/weapp/dist/notify/notify和‘selectComponent‘ of undefined
**
微信小程序搭配vantweapp引入notify消息提示組件
/path/to/@vant/weapp/dist/notify/notify未找到
‘selectComponent‘ of undefined報錯
解決辦法:
** import引入相對路徑
Notify({ type: ‘success', message: ‘通知內(nèi)容' });//放入事件中
對應(yīng)js文件代碼:
import Notify from '../../miniprogram_npm/@vant/weapp/notify/notify';
Page({
data: {},
//btnSub是事件名
btnSub() {
Notify({ type: 'success', message: '通知'});
}
})
wxml文件代碼
<van-notify id="van-notify" />
app.json文件代碼
"usingComponents": {
"van-notify": "@vant/weapp/notify/index"
}
以上這篇使用Vant完成通知欄Notify的提示操作就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
vue中設(shè)置height:100%無效的問題及解決方法
這篇文章主要介紹了vue中設(shè)置height 100%無效的問題及解決方法,需要的朋友可以參考下2018-07-07
el-table樹形數(shù)據(jù)量過大,導(dǎo)致頁面卡頓問題及解決
這篇文章主要介紹了el-table樹形數(shù)據(jù)量過大,導(dǎo)致頁面卡頓問題及解決,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-04-04
Vue處理循環(huán)數(shù)據(jù)流程示例精講
這篇文章主要介紹了Vue處理循環(huán)數(shù)據(jù)流程,這個又是一個編程語言,?模版語法里面必不可少的一個,?也是使用業(yè)務(wù)場景使用最多的一個環(huán)節(jié)。所以學(xué)會使用循環(huán)也是重中之重了2023-04-04
Vue切換組件實現(xiàn)返回后不重置數(shù)據(jù),保留歷史設(shè)置操作
這篇文章主要介紹了Vue切換組件實現(xiàn)返回后不重置數(shù)據(jù),保留歷史設(shè)置操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-07-07
el-select自定義指令實現(xiàn)觸底加載分頁請求options數(shù)據(jù)(完整代碼和接口可直接用)
某些情況下,下拉框需要做觸底加載,發(fā)請求,獲取option的數(shù)據(jù),下面給大家分享el-select自定義指令實現(xiàn)觸底加載分頁請求options數(shù)據(jù)(附上完整代碼和接口可直接用),感興趣的朋友參考下吧2024-02-02

