TabLanguage.vue
1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<template>
<div class="xn-fixed" >
<li class="li" @click="setLocale"><span v-if="locale=='cn'">EN</span><span v-else="locale=='en'">CN</span></li>
<li class="li to-top" @click="goTop"></li>
</div>
</template>
<script>
import Vue from 'vue'
import { Header } from 'mint-ui';
import { Button } from 'mint-ui';
Vue.component(Header.name, Header);
Vue.component(Button.name, Button);
export default {
name: 'xnHeader',
data () {
return {
is_fixed:true
}
},
methods: {
setLocale:function () {
if(this.$i18n.locale=="en"){
this.$i18n.locale="cn";
}else {
this.$i18n.locale="en";
}
},
goTop:function(){
document.querySelector(".xn-main").scrollTop=0;
}
},
computed:{
locale:function () {
return this.$i18n.locale;
}
}
};
</script>
<style lang="less" scoped>
.xn-fixed{
position: fixed;
right: 0.625rem;
bottom: 0.625rem;
width: 1.0625rem;
height: 2.5rem;
}
.xn-fixed .li{
width: 1.0625rem;
height: 1.0625rem;
margin-bottom: 0.25rem;
border-radius: 50%;
background: #2368f3;
color: #fff;
display:flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
justify-content: center;
box-shadow: 0 2px 5px #dbdbdb;
}
.xn-fixed .to-top{
margin-bottom:0;
background: #fff url("../../../assets/images/toTop.png") center 50% no-repeat;
background-size: 70% 70%;
}
</style>