e753b4da by 任超

style:通知公告

1 parent 45ae0008
1 <template>
2 <div class="my-outbox">
3 <div class="my-inbox" ref='box'>
4 <div class="my-list" :style="note" v-for="(item,index) in sendVal" :key='index' ref='list'>
5 <span class="my-uname">{{ item }}</span>
6 </div>
7 </div>
8 </div>
9 </template>
10
11 <script>
12 export default {
13 name: 'my-marquee-left',
14 props: {
15 sendVal: {
16 type: Array,
17 default: []
18 }
19 },
20 data () {
21 return {
22 note: {
23 backgroundSize: "20px 20px",
24 backgroundRepeat: "no-repeat",
25 backgroundPosition: "1% 50%"
26 },
27 // 定时器标识
28 nowTime: null,
29 // 每一个内容的宽度
30 disArr: []
31 }
32 },
33 mounted () {
34 // var that = this
35 var item = this.$refs.list
36 var len = this.sendVal.length
37 var arr = []
38 // 因为设置的margin值一样,所以取第一个就行。
39 var margin = this.getMargin(item[0])
40 for (var i = 0; i < len; i++) {
41 arr.push(item[i].clientWidth + margin) // 把宽度和 margin 加起来就是每一个元素需要移动的距离
42 }
43 this.disArr = arr
44 this.moveLeft()
45 },
46 beforeDestroy () {
47 // 页面关闭清除定时器
48 clearInterval(this.nowTime)
49 // 清除定时器标识
50 this.nowTime = null
51 },
52 methods: {
53 // 获取margin属性
54 getMargin (obj) {
55 var marg = window.getComputedStyle(obj, null)['margin-right']
56 marg = marg.replace('px', '')
57 return Number(marg) // 强制转化成数字
58 },
59 // 移动的方法
60 moveLeft () {
61 var that = this
62 var outbox = this.$refs.box
63 // 初始位置
64 var startDis = 0
65 // console.log('that.disArr: ', that.disArr)
66 this.nowTime = setInterval(function () {
67 startDis -= 0.5
68 // console.log('初始化移动:', startDis)
69 if (Math.abs(startDis) > Math.abs(that.disArr[0])) {
70 // 每次移动完一个元素的距离,就把这个元素的宽度
71 that.disArr.push(that.disArr.shift())
72 // 每次移动完一个元素的距离,就把列表数据的第一项放到最后一项
73 // console.log('that.sendVal: ', that.sendVal)
74 // console.log('that.sendVal: ', that.sendVal.shift())
75 that.sendVal.push(that.sendVal.shift())
76 startDis = 0
77 // console.log('移动')
78 } else {
79 // console.log('不来不来就不来...')
80 }
81 // 每次都让盒子移动指定的距离,在我自己做的项目中,这种字符串拼接的方法并没有生效
82 // outbox.style = 'transform: translateX3d(' + startDis + 'px)'
83 // 后面换了es6的模板字符串就可以了
84 outbox.style = `transform: translateX(${startDis}px)`
85 // outbox.style = 'transform: translateX(\' + startDis + \' px)'
86 // outbox.style.marginLeft = 'startDis'
87 // console.log('这里:', startDis)
88 }, 1000 / 60)
89 }
90 }
91 }
92 </script>
93
94 <style lang="scss" scoped>
95 .my-outbox {
96 color: #fff;
97 overflow: hidden;
98 line-height: 28px;
99 // background: $light-blue;
100 width: 500px;
101
102 .my-inbox {
103 white-space: nowrap;
104
105 .my-list {
106 margin-right: 15px;
107 display: inline-block;
108 font-size: 14px;
109 text-indent: 30px;
110
111 .my-uname {
112 color: #fff;
113 }
114 }
115 }
116 }
117 </style>
...\ No newline at end of file ...\ No newline at end of file
1 <template> 1 <template>
2 <div class="navbar" v-theme.background="mTheme"> 2 <div class="navbar-con">
3 <div class="logo"> 3 <div class="navbar" v-theme.background="mTheme">
4 <img v-if="logo" :src="logo" class="header-logo"> 4 <div class="logo">
5 </div> 5 <img v-if="logo" :src="logo" class="header-logo">
6 <div class="backdrop"> 6 </div>
7 <theme style="float: right;height: 26px;width: 26px;margin-top: 26px;" @change="themeChange" /> 7 <div class="backdrop">
8 </div> 8 <theme style="float: right;height: 26px;width: 26px;margin-top: 26px;" @change="themeChange" />
9 <div class="right-menu"> 9 </div>
10 <el-dropdown class="avatar-container right-menu-item hover-effect" @command="handleCommand"> 10 <div class="right-menu">
11 <div class="avatar-wrapper"> 11 <el-dropdown class="avatar-container right-menu-item hover-effect" @command="handleCommand">
12 <span style="padding-right:10px">{{ name }}</span> 12 <div class="avatar-wrapper">
13 <img :src="avatar + '?imageView2/1/w/80/h/80'" class="user-avatar" /> 13 <span style="padding-right:10px">{{ name }}</span>
14 </div> 14 <img :src="avatar + '?imageView2/1/w/80/h/80'" class="user-avatar" />
15 <el-dropdown-menu slot="dropdown"> 15 </div>
16 <el-dropdown-item command="a">个人中心</el-dropdown-item> 16 <el-dropdown-menu slot="dropdown">
17 <el-dropdown-item command="f">退出登录</el-dropdown-item> 17 <el-dropdown-item command="a">个人中心</el-dropdown-item>
18 </el-dropdown-menu> 18 <el-dropdown-item command="f">退出登录</el-dropdown-item>
19 </el-dropdown> 19 </el-dropdown-menu>
20 </el-dropdown>
21 </div>
20 </div> 22 </div>
23 <NoticeBar class="NoticeBar" :sendVal="sendVal" />
21 </div> 24 </div>
22 </template> 25 </template>
23 <script> 26 <script>
27 import NoticeBar from '@/components/NoticeBar/index'
24 import { mapGetters } from 'vuex' 28 import { mapGetters } from 'vuex'
25 export default { 29 export default {
30 components: {
31 NoticeBar
32 },
26 computed: { 33 computed: {
27 ...mapGetters(['sidebar', 'avatar', 'name']) 34 ...mapGetters(['sidebar', 'avatar', 'name'])
28 }, 35 },
29 data () { 36 data () {
30 return { 37 return {
31 logo: require('../../image/logo.png') 38 logo: require('../../image/logo.png'),
39 sendVal: [
40 '222222222222222222222222222222222',
41 '222222233333333333333333333333'
42 ]
32 } 43 }
33 }, 44 },
34 methods: { 45 methods: {
...@@ -53,6 +64,16 @@ export default { ...@@ -53,6 +64,16 @@ export default {
53 } 64 }
54 </script> 65 </script>
55 <style lang="scss" scoped> 66 <style lang="scss" scoped>
67 .navbar-con {
68 position: relative;
69 }
70
71 .NoticeBar {
72 position: absolute;
73 left: 330px;
74 bottom: 0;
75 }
76
56 .el-dropdown-menu { 77 .el-dropdown-menu {
57 padding: 0 !important; 78 padding: 0 !important;
58 border: 1px solid #EBEEF5; 79 border: 1px solid #EBEEF5;
......
...@@ -72,6 +72,7 @@ class data extends filter { ...@@ -72,6 +72,7 @@ class data extends filter {
72 }, 72 },
73 { 73 {
74 label: "操作", 74 label: "操作",
75 width: 80,
75 render: (h, scope) => { 76 render: (h, scope) => {
76 return <el-button type="text" icon='el-icon-view' onClick={() => { vm.handleViewClick(scope) }}>查看</el-button> 77 return <el-button type="text" icon='el-icon-view' onClick={() => { vm.handleViewClick(scope) }}>查看</el-button>
77 } 78 }
......
...@@ -85,6 +85,9 @@ ...@@ -85,6 +85,9 @@
85 padding-left: 5px !important; 85 padding-left: 5px !important;
86 } 86 }
87 87
88 /deep/.el-menu {
89 border-right: none;
90 }
88 91
89 92
90 /deep/.el-menu-item.is-active { 93 /deep/.el-menu-item.is-active {
......