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

Element Notification通知的實現(xiàn)示例

 更新時間:2020年07月27日 10:53:36   作者:ForeverJPB.  
這篇文章主要介紹了Element Notification通知的實現(xiàn)示例,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

組件— 通知

基本用法


<template>
 <el-button
  plain
  @click="open1">
  可自動關(guān)閉
 </el-button>
 <el-button
  plain
  @click="open2">
  不會自動關(guān)閉
  </el-button>
</template>

<script>
 export default {
  methods: {
   open1() {
    const h = this.$createElement;

    this.$notify({
     title: '標(biāo)題名稱',
     message: h('i', { style: 'color: teal'}, '這是提示文案這是提示文案這是提示文案這是提示文案這是提示文案這是提示文案這是提示文案這是提示文案')
    });
   },

   open2() {
    this.$notify({
     title: '提示',
     message: '這是一條不會自動關(guān)閉的消息',
     duration: 0
    });
   }
  }
 }
</script>

帶有傾向性

<template>
 <el-button
  plain
  @click="open1">
  成功
 </el-button>
 <el-button
  plain
  @click="open2">
  警告
 </el-button>
 <el-button
  plain
  @click="open3">
  消息
 </el-button>
 <el-button
  plain
  @click="open4">
  錯誤
 </el-button>
</template>

<script>
 export default {
  methods: {
   open1() {
    this.$notify({
     title: '成功',
     message: '這是一條成功的提示消息',
     type: 'success'
    });
   },

   open2() {
    this.$notify({
     title: '警告',
     message: '這是一條警告的提示消息',
     type: 'warning'
    });
   },

   open3() {
    this.$notify.info({
     title: '消息',
     message: '這是一條消息的提示消息'
    });
   },

   open4() {
    this.$notify.error({
     title: '錯誤',
     message: '這是一條錯誤的提示消息'
    });
   }
  }
 }
</script>

自定義彈出位置

<template>
 <el-button
  plain
  @click="open1">
  右上角
 </el-button>
 <el-button
  plain
  @click="open2">
  右下角
 </el-button>
 <el-button
  plain
  @click="open3">
  左下角
 </el-button>
 <el-button
  plain
  @click="open4">
  左上角
 </el-button>
</template>

<script>
 export default {
  methods: {
   open1() {
    this.$notify({
     title: '自定義位置',
     message: '右上角彈出的消息'
    });
   },

   open2() {
    this.$notify({
     title: '自定義位置',
     message: '右下角彈出的消息',
     position: 'bottom-right'
    });
   },

   open3() {
    this.$notify({
     title: '自定義位置',
     message: '左下角彈出的消息',
     position: 'bottom-left'
    });
   },

   open4() {
    this.$notify({
     title: '自定義位置',
     message: '左上角彈出的消息',
     position: 'top-left'
    });
   }
  }
 }
</script>

帶有偏移


<template>
 <el-button
  plain
  @click="open">
  偏移的消息
 </el-button>
</template>

<script>
 export default {
  methods: {
   open() {
    this.$notify({
     title: '偏移',
     message: '這是一條帶有偏移的提示消息',
     offset: 100
    });
   }
  }
 }
</script>

使用 HTML 片段


<template>
 <el-button
  plain
  @click="open">
  使用 HTML 片段
 </el-button>
</template>

<script>
 export default {
  methods: {
   open() {
    this.$notify({
     title: 'HTML 片段',
     dangerouslyUseHTMLString: true,
     message: '<strong>這是 <i>HTML</i> 片段</strong>'
    });
   }
  }
 }
</script>

隱藏關(guān)閉按鈕


<template>
 <el-button
  plain
  @click="open">
  隱藏關(guān)閉按鈕
 </el-button>
</template>

<script>
 export default {
  methods: {
   open() {
    this.$notify.success({
     title: 'Info',
     message: '這是一條沒有關(guān)閉按鈕的消息',
     showClose: false
    });
   }
  }
 }
</script>

全局方法

Element 為 Vue.prototype 添加了全局方法 $notify。因此在 vue instance 中可以采用本頁面中的方式調(diào)用 Notification。

單獨引用

Options


方法

Vue項目中Element的Notification通知若干問題

要求是后臺推送過來一條消息,前端接收后再將消息進(jìn)行提煉后通過彈窗通知用戶。前后端發(fā)送接收消息用的技術(shù)是webIm,這個先不提了,官方文檔配置一下就OK了。

遇到的問題是產(chǎn)品給的設(shè)計圖與Element的出入很大,所以就使用了Element的dangerouslyUseHTMLString屬性,即把需要發(fā)送的消息寫成HTML結(jié)構(gòu)發(fā)送

在模板字符串中,加載圖片那里發(fā)現(xiàn)路徑無法實現(xiàn)圖片的加載,試了很多種方法,發(fā)現(xiàn)使用require+${}的方法最好用,上圖中<img src=${this.imgUrlNormal}>中,${}保存的地址需要先在data里邊return出來

這個問題就解決了。

第二個問題是遇到了樣式的調(diào)整問題,Element的權(quán)重太高,真的是不太好搞,在網(wǎng)上找了很多解決方案,發(fā)現(xiàn)把<style>標(biāo)簽中的scoped去掉這種方法可以解決問題。

并且用到了costomClass這個屬性,這個屬性是給元素添加一個class類名,自己來添加樣式。

這樣,這個彈窗的問題就解決了。

到此這篇關(guān)于Element Notification通知的實現(xiàn)示例的文章就介紹到這了,更多相關(guān)Element Notification通知內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

永宁县| 嫩江县| 淄博市| 霞浦县| 明光市| 尚志市| 北京市| 当阳市| 灵山县| 肇庆市| 无棣县| 金堂县| 泰州市| 湟中县| 民权县| 凤山市| 衡南县| 望都县| 张家界市| 凤翔县| 吴江市| 五指山市| 龙川县| 普安县| 台东县| 大同县| 资源县| 长沙市| 渝北区| 什邡市| 台山市| 长子县| 嘉义县| 迭部县| 荔浦县| 辽源市| 彩票| 通渭县| 中西区| 乐陵市| 右玉县|