vue 백그라운드 관리에 다중 언어 기능 추가의 실현 예시
1. 우선 메인.js 페이지 설정
import VueI18n from 'vue-i18n'
Vue.use(VueI18n) //
const i18n = new VueI18n({
//locale: 'zh-CN', //
locale: 'Chinese', //
//this.$i18n.locale // locale
messages: {
'Chinese': require('./common/lang/zh'), //
'English': require('./common/lang/en') //
},
//
silentTranslationWarn: true
})
new Vue({
el: '#app',
router,
i18n,
components: { App },
template: '<App/>'
})
2. 상응하는 경로 아래의 언어 패키지를 설정하고 여기에 일부 코드만 표시하며 필요한 것은 여기에 추가하면 된다
en.js
export const m = {
deviceCode: 'Device Code',//
deviceName: 'Device Name',//
deviceType: 'Device Type',//
denial: 'Denial',//
camera: 'Camera',//
}
zh.js
export const m = {
deviceCode: ' ',//
deviceName: ' ',//
deviceType: ' ',//
denial: ' ',//
camera: ' ',//
}
3. 페이지에서 사용, 다른 곳에서 사용, 쓰기가 약간 다르다
(1)placeholder
<el-row :gutter="30">
<el-col :span="4">
<div class="grid-content bg-purple">
<el-input v-model="value0" :placeholder="$t('m.placeOne')"></el-input>
</div>
</el-col>
<el-col :span="8">
<div class="grid-content bg-purple">
<el-button @click="searchData()" type="primary" icon="el-icon-search">{{ $t('m.query') }}</el-button>
<el-button @click="dialogVisible = true" type="warning">{{ $t('m.AddDevice') }}</el-button>
</div>
</el-col>
</el-row>(2)table
<el-table
:data="tableData"
stripe
style="width: 100%;">
<el-table-column
prop="areaName"
:label="$t('m.areaName')"
width="100">
</el-table-column>
</el-table>
(3)
<el-dialog :title="$t('m.Ediedevice')" :visible.sync="dialogVisibles" width="30%" :before-close="handleClose" :close-on-click-modal=false>
<edit-equipment @subsuccess="subsuccess" :editDate="editDate" style="overflow: hidden;"></edit-equipment>
</el-dialog>
(4)js
strHtml = strHtml + "<td>"+this.$i18n.t('m.deviceCode')+":</td>";
이상은 vue 백그라운드 관리에 다중 언어 기능을 추가하는 실현 예시의 상세한 내용입니다. vue 백그라운드 관리에 다중 언어 기능을 추가하는 것에 대한 더 많은 자료는 저희 다른 관련 글을 주목해 주십시오!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Fastapi websocket 및 vue 3(Composition API)1부: FastAPI virtualenv 만들기(선택 사항) FastAPI 및 필요한 모든 것을 다음과 같이 설치하십시오. 생성main.py 파일 및 실행 - 브라우저에서 이 링크 열기http://127.0.0.1:...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.