Language.vue
3.6 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<template>
<div>
<!-- <div style="position: relative;">
<transition name="el-fade-in">
<div style="position: absolute;bottom:40px;width:100px;padding:0 10px;background-color:rgba(255,255,255,0.2); margin-left: -10px;" v-show="flag">
<div style="">
<div v-for="(v,i) in options" :key="i" @click="changeLang(v)" style="padding:10px 0 5px;text-align: left;">{{v.label}}</div>
</div>
<span><img style="width:10px;height:7px;position: absolute;" src="../assets/img/op03.png" alt=""></span>
</div>
</transition>
<div @click="open" style="width:100px;border:1px solid rgba(255,255,255,0.2); line-height:24px">
<span style="font-weight: bold;">
{{value}}
</span>
<i><img :class="{'rota':!flag}" style="width:10px;height:10px;" src="../assets/img/op07.png" alt=""></i>
</div>
</div> -->
<el-popover
placement="top"
width="80"
v-model="visible">
<i class="arrow"><img class="arrow-img" src="../assets/img/op03.png" alt=""></i>
<div class="lans" v-for="(v,i) in options" :key="i" @click="changeLang(v)" style="color: rgba(255,255,255,0.6);">{{v.label}}</div>
<el-button @click="open" slot="reference">
<label style="font-weight: bold; color: rgba(255,255,255,0.6);">{{$t('language.name')}}</label>
<i style="margin-left:8px"><img :class="{'rota':!visible}" style="width:15px;height:8px;" src="../assets/img/op07.png" alt=""></i>
</el-button>
</el-popover>
</div>
</template>
<script>
export default {
name:'Language',
data() {
return {
visible: false,
rota:'rota',
flag:false,
options: [
{
value: 'cn',
label: '繁体中文'
},
{
value: 'zh',
label: '简体中文'
}, {
value: 'en',
label: 'English'
}, {
value: 'ja',
label: '日本語'
}],
value: 'Language'
}
},
created() {
// let lang = document.documentElement.lang;
// localStorage.setItem("lang", lang);
// this.toActive(lang);
},
methods: {
open(){
this.flag=!this.flag;
},
changeLang(v) {
this.visible = false;
this.open();
// let lang = e.target.innerText;
let lang = v.value
this.$i18n.locale = lang;
localStorage.setItem("lang", lang);
this.value = v.label;
// this.toActive(lang);
},
// toActive(lang) {
// this.isActive = lang == "zh" ? true : false;
// }
}
}
</script>
<style lang="less" scoped>
.rota{
transform: rotate(180deg);
}
/deep/ .el-button {
background: transparent;
color: #FFF;
padding: 10px;
min-width: 100px;
width: 110px;
}
.arrow{
position: absolute;
display: block;
bottom: 0;
left: 50%;
margin-left: -7px;
}
.arrow-img{
width:15px;height:7px;position: absolute;
}
.lans{
padding:7px 0 0 17px;text-align: left;cursor: pointer;color:white;
}
.lans:hover{
background-color: rgba(255,255,255,0.2) !important;
}
// /deep/ .el-input--suffix .el-input__inner {
// padding-right: 30px;
// background-color: rgba(255,255,255,0);
// border:none !important;
// }
// /deep/.el-select-dropdown {
// position: absolute;
// z-index: 1001;
// border: 1px solid #E4E7ED;
// border-radius: 4px;
// background-color: rgba(255,255,255,0);
// box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
// box-sizing: border-box;
// margin: 5px 0;
// color: white;
// }
// /deep/ .el-form-item__error{
// color: rgb(0 120 212);
// }
</style>