Giter VIP home page Giter VIP logo

bacchusgift / infinite-notice-bar Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 1.0 96 KB

Infinite scroll notice bar! You can use just simple array or more complex config to define your notice bar! 无限滚动消息通知栏, 你可以用简单的数组来直接定义一个滚动通知,也可以启用更复杂,甚至自定义背景的通知栏

License: MIT License

HTML 0.86% Vue 96.70% JavaScript 2.44%

infinite-notice-bar's Introduction

Infinite-Notice-Bar

无限滚动的消息通知栏,简单实用,适用于任意场景,长度高度可定制

  • 使用方式:

    • 一个条完整的通知由下面的json组成

    • {
          name:"马化腾",
          icon:"http://.......",
          action:"得到", // 可以没有,将会被默认替代,也可以在插槽中直接书写想要的action关键字
          content:"法拉利",
          timeStr:"1秒前"
      }

就像这样 !

  • 将src目录下,infinite-notice-bar.vue 拷贝出来
  • 放到自己的目录
  • 页面中引入此组件
  • 如下
  <template>
    <div>
      // 建议放在任意位置使用绝对定位将通知栏定位 
      // 若是非H5应用(没有做rem和px的转换) 大小需要自行调整
      <NoticeBar
          class="notice-bar"
          has-icon
          bar-color="rgba(255,255,255,0.5)" // 通知栏组件的颜色,建议使用rgba,可以设置透明度,最后一位0.5即是透明度
          :notice-list="noticeList" // 可以传入一个复杂的list,不可以和simple-list共存
          :simple-list="simpleList" // 可以传入一个简单的list,不可以和notice-list共存
          time-str // 默认有时间戳文字 ( 3s前 ,1s前 这样) 
         >//直接写action文字可以直接替换(action看说明文档)</NoticeBar>
    </div>	
  </template>
  <script>
    import NoticeBar from './infinite-notice-bar/infinite-notice-bar'
    export default {
    name: 'NoticeBar',
    data () {
      return {
        number: 0,
        simpleList: [
          "你在说什么?",
          "你要给我一个赞吗?"
        ],
        noticesList: [
          {
            name: '哈哈哈',
            icon: 'http://youlehe-pic.yiyayouxi.com/icon/900001.jpg',
            content: 'vivo X27Pro',
            timeStr: '3秒前'
          },
          {
            name: '啦啦啦',
            icon: 'http://youlehe-pic.yiyayouxi.com/icon/900001.jpg',
            content: 'vivo X27Pro',
            timeStr: '3秒前'
          }
        ]
      }
    }
  }
  </script>
  <style scoped>
  </style>
字段 含义 示例 默认值
has-icon 是否包含icon,如果是,则需要在传入的noticeList里增加icon的字段 true锁定 true
simpleList 简单的消息列表,是一个字符串数组 ["a","b","c"] -
bar-color 通知条背景颜色,除了颜色也可以传入图片(css的background格式) Rgba(255,255,255,0.5)#FFFFFF url("图片的地址") Rgba(255,255,255,0.5)
font-size 通知栏文字的大小 0.3rem,100px,20% 35%
time-str 是否包含最后的时间返回指示 true true
speed 滚动停留时间 ms 3000 2000
content-color 奖品文字颜色(如果是simple模式,此字段失效) Rgba(255,255,255,1)#FFFFFF #c95354
width 通知栏的长度 85%9rem 9rem
height 通知栏的高度 1.2rem 1.2rem
action 用户领取动作(如 xx 得到了 XX) 得到 得到

Tips:

插槽写的东西会自动替换掉action的默认文字!

<NoticeBar
 class="notice-bar"
 :notice-list="noticeList"
  timeStr
 >
  领取了
</NoticeBar>

如上, 你的noticeList如果是这样的

{
	name:"柚子",
	content:"地球",
	icon:"http://sdsdsd.png"
}

那么,你的通知将会变成:

柚子 领取了 地球 2秒前


Ok~ 快来使用吧

infinite-notice-bar's People

Contributors

bacchusgift avatar

Stargazers

 avatar shaoyaohua avatar sky avatar KaimingY avatar Carey avatar

Watchers

James Cloos avatar

Forkers

duwenink

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.