最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

使用Vant如何完成各種Toast提示框

 更新時(shí)間:2022年05月26日 14:11:10   作者:檸檬不萌只是酸i  
這篇文章主要介紹了使用Vant如何完成各種Toast提示框,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

Vant完成各種Toast提示框

效果展示

(1)使用前的需要安裝Vant奧。 

(2)在main.js里面引入Toast

import { Toast } from 'vant';
Vue.use(Toast);

(3)在頁面使用:(根據(jù)步驟代碼可以運(yùn)行奧  Toast.vue文件)(上面截圖的,在下面代碼都有栗子奧)。

<template>
? <!-- Toast提示 -->
? <div id="toast">
? ? <van-button plain type="primary" @click="toToast">普通文字提示</van-button>
? ? <van-button plain type="primary" @click="toLoading">加載轉(zhuǎn)圈提示</van-button>
? ? <van-button plain type="primary" @click="toSuccessTip">成功提示</van-button>
? ? <van-button plain type="primary" @click="toFailTip">失敗提示</van-button>
? ? <van-button plain type="primary" @click="toCustomIcon">自定義圖標(biāo)提示</van-button>
? ? <van-button plain type="primary" @click="toCustomImage">自定義圖片提示</van-button>
? </div>
</template>
<script>
? export default {
? ? data() {
? ? ? return {
? ? ? ? msg: ''
? ? ? }
? ? },
? ? // 引入 Toast 組件后,會(huì)自動(dòng)在 Vue 的 prototype 上掛載 $toast 方法,便于在組件內(nèi)調(diào)用。
? ? methods: {
? ? ? // 普通文字提示
? ? ? toToast() {
? ? ? ? this.$toast({
? ? ? ? ? message:'我是需要提示的文字',
? ? ? ? ? position:'top'
? ? ? ? });
? ? ? },
?
? ? ? // 加載轉(zhuǎn)圈提示
? ? ? toLoading() {
? ? ? ? this.$toast.loading({
? ? ? ? ? mask: true,
? ? ? ? ? message: '加載中...'
? ? ? ? });
? ? ? },
?
? ? ? // 成功提示
? ? ? toSuccessTip() {
? ? ? ? this.$toast.success({
? ? ? ? ? message:'成功的提示文案',
? ? ? ? })
? ? ? },
?
? ? ? // 失敗提示
? ? ? toFailTip() {
? ? ? ? this.$toast.fail({
? ? ? ? ? message:'失敗的提示文案'
? ? ? ? })
? ? ? },
?
? ? ? // ? 自定義圖標(biāo)
? ? ? toCustomIcon() {
? ? ? ? this.$toast({
? ? ? ? ? icon: 'star-o', // 找到自己需要的圖標(biāo)
? ? ? ? ? message: '我是提示文字'
? ? ? ? })
? ? ? },
?
? ? ? //自定義圖片提示
? ? ? toCustomImage() {
? ? ? ? this.$toast({
? ? ? ? ? icon:'https://www.baidu.com/favicon.ico',
? ? ? ? ? message:'我是提示文字'
? ? ? ? })
? ? ? }
?
? ? },
? ? mounted() {
?
? ? }
? }
</script>

  

<style>
</style>

(4)Toast的相關(guān)API和Options 點(diǎn)擊去查看

更新補(bǔ)充

position 里面的高度不局限與 top bottom等,也可設(shè)置數(shù)值,例如: 

this.$toast({
    message:'我是需要提示的文字',
    position:'200px'   // 彈框的位置可以自己設(shè)置
});

Vant Toast用法

題外話就不多講了,這是圍繞vue.js寫的,愛上vue.js

1.首先引入

import { Toast } from 'vant'

寫個(gè)小列子

綁定一個(gè)click事件

2.寫事件

在methods寫方法

showToast() {
                this.$toast({
                    message: "今日簽到+3",
                  })
      },

3.效果圖如下

一個(gè)簡(jiǎn)單的toast提示成就好了

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。 

相關(guān)文章

最新評(píng)論

元朗区| 昆明市| 宜城市| 芒康县| 阳西县| 扶余县| 元江| 涪陵区| 清流县| 区。| 绥宁县| 新疆| 手机| 嘉禾县| 呼和浩特市| 城固县| 绥滨县| 沙坪坝区| 赫章县| 吕梁市| 石狮市| 泰州市| 银川市| 那坡县| 孟村| 陈巴尔虎旗| 九江县| 云浮市| 习水县| 白山市| 大荔县| 合阳县| 金阳县| 张家港市| 土默特左旗| 托里县| 娱乐| 内江市| 遂川县| 都兰县| 利川市|