Files
sist_web/src/views/Home.vue
2021-12-27 23:05:09 +08:00

60 lines
892 B
Vue

<template>
<div class="hello">
<p>{{$t('message.hello')}}</p>
<button @click="switchLang">{{$t('message.switch')}}</button>
<div>
<About/>
</div>
</div>
</template>
<script>
import {test} from '@/api/test'
import About from './About'
export default {
name: 'HelloWorld',
components: {
About
},
data () {
return {
}
},
computed: {
label () {
return this.$t('message.hello')
}
},
methods: {
switchLang () {
test().then(res =>{
console.log(res)
})
let lang = ''
if (this.$i18n.locale === 'en') {
lang = 'cn'
} else {
lang = 'en'
}
this.$i18n.locale = lang;
}
}
}
</script>
<style scoped>
h1,
h2 {
font-weight: normal;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>