mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
docs(Field): update i18n usage
This commit is contained in:
parent
3452ee2a41
commit
65e14cd84a
@ -11,26 +11,29 @@
|
||||
</demo-block>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { useTranslate } from '@demo/use-translate';
|
||||
|
||||
const i18n = {
|
||||
'zh-CN': {
|
||||
message: '留言',
|
||||
autosize: '高度自适应',
|
||||
placeholder: '请输入留言',
|
||||
},
|
||||
'en-US': {
|
||||
sms: 'SMS',
|
||||
autosize: 'Auto Resize',
|
||||
placeholder: 'Message',
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
i18n: {
|
||||
'zh-CN': {
|
||||
message: '留言',
|
||||
autosize: '高度自适应',
|
||||
placeholder: '请输入留言',
|
||||
},
|
||||
'en-US': {
|
||||
sms: 'SMS',
|
||||
autosize: 'Auto Resize',
|
||||
placeholder: 'Message',
|
||||
},
|
||||
},
|
||||
|
||||
setup() {
|
||||
const t = useTranslate(i18n);
|
||||
const value = ref('');
|
||||
return { value };
|
||||
|
||||
return { t, value };
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -10,24 +10,26 @@
|
||||
</demo-block>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { useTranslate } from '@demo/use-translate';
|
||||
|
||||
const i18n = {
|
||||
'zh-CN': {
|
||||
label: '文本',
|
||||
placeholder: '请输入文本',
|
||||
},
|
||||
'en-US': {
|
||||
label: 'Label',
|
||||
placeholder: 'Text',
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
i18n: {
|
||||
'zh-CN': {
|
||||
label: '文本',
|
||||
placeholder: '请输入文本',
|
||||
},
|
||||
'en-US': {
|
||||
label: 'Label',
|
||||
placeholder: 'Text',
|
||||
},
|
||||
},
|
||||
|
||||
setup() {
|
||||
const t = useTranslate(i18n);
|
||||
const value = ref('');
|
||||
return { value };
|
||||
return { t, value };
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -32,38 +32,40 @@
|
||||
</demo-block>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { reactive, toRefs } from 'vue';
|
||||
import { useTranslate } from '@demo/use-translate';
|
||||
|
||||
const i18n = {
|
||||
'zh-CN': {
|
||||
text: '文本',
|
||||
digit: '整数',
|
||||
phone: '手机号',
|
||||
number: '数字',
|
||||
customType: '自定义类型',
|
||||
smsPlaceholder: '请输入短信验证码',
|
||||
textPlaceholder: '请输入文本',
|
||||
digitPlaceholder: '请输入整数',
|
||||
phonePlaceholder: '请输入手机号',
|
||||
numberPlaceholder: '请输入数字(支持小数)',
|
||||
},
|
||||
'en-US': {
|
||||
text: 'Text',
|
||||
digit: 'Digit',
|
||||
phone: 'Phone',
|
||||
number: 'Number',
|
||||
customType: 'Custom Type',
|
||||
smsPlaceholder: 'SMS',
|
||||
textPlaceholder: 'Text',
|
||||
digitPlaceholder: 'Digit',
|
||||
phonePlaceholder: 'Phone',
|
||||
numberPlaceholder: 'Number',
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
i18n: {
|
||||
'zh-CN': {
|
||||
text: '文本',
|
||||
digit: '整数',
|
||||
phone: '手机号',
|
||||
number: '数字',
|
||||
customType: '自定义类型',
|
||||
smsPlaceholder: '请输入短信验证码',
|
||||
textPlaceholder: '请输入文本',
|
||||
digitPlaceholder: '请输入整数',
|
||||
phonePlaceholder: '请输入手机号',
|
||||
numberPlaceholder: '请输入数字(支持小数)',
|
||||
},
|
||||
'en-US': {
|
||||
text: 'Text',
|
||||
digit: 'Digit',
|
||||
phone: 'Phone',
|
||||
number: 'Number',
|
||||
customType: 'Custom Type',
|
||||
smsPlaceholder: 'SMS',
|
||||
textPlaceholder: 'Text',
|
||||
digitPlaceholder: 'Digit',
|
||||
phonePlaceholder: 'Phone',
|
||||
numberPlaceholder: 'Number',
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
setup() {
|
||||
const t = useTranslate(i18n);
|
||||
const state = reactive({
|
||||
text: '',
|
||||
phone: '',
|
||||
@ -72,7 +74,10 @@ export default {
|
||||
password: '',
|
||||
});
|
||||
|
||||
return toRefs(state);
|
||||
return {
|
||||
...toRefs(state),
|
||||
t,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -5,20 +5,28 @@
|
||||
</demo-block>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { useTranslate } from '@demo/use-translate';
|
||||
|
||||
const i18n = {
|
||||
'zh-CN': {
|
||||
text: '文本',
|
||||
disabled: '禁用输入框',
|
||||
inputReadonly: '输入框只读',
|
||||
inputDisabled: '输入框已禁用',
|
||||
},
|
||||
'en-US': {
|
||||
text: 'Text',
|
||||
inputReadonly: 'Input Readonly',
|
||||
inputDisabled: 'Input Disabled',
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
i18n: {
|
||||
'zh-CN': {
|
||||
text: '文本',
|
||||
disabled: '禁用输入框',
|
||||
inputReadonly: '输入框只读',
|
||||
inputDisabled: '输入框已禁用',
|
||||
},
|
||||
'en-US': {
|
||||
text: 'Text',
|
||||
inputReadonly: 'Input Readonly',
|
||||
inputDisabled: 'Input Disabled',
|
||||
},
|
||||
setup() {
|
||||
const t = useTranslate(i18n);
|
||||
|
||||
return { t };
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -17,32 +17,37 @@
|
||||
</demo-block>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { reactive, toRefs } from 'vue';
|
||||
import { useTranslate } from '@demo/use-translate';
|
||||
|
||||
const i18n = {
|
||||
'zh-CN': {
|
||||
phone: '手机号',
|
||||
errorInfo: '错误提示',
|
||||
phoneError: '手机号格式错误',
|
||||
phonePlaceholder: '请输入手机号',
|
||||
},
|
||||
'en-US': {
|
||||
phone: 'Phone',
|
||||
errorInfo: 'Error Info',
|
||||
phoneError: 'Invalid phone',
|
||||
phonePlaceholder: 'Phone',
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
i18n: {
|
||||
'zh-CN': {
|
||||
phone: '手机号',
|
||||
errorInfo: '错误提示',
|
||||
phoneError: '手机号格式错误',
|
||||
phonePlaceholder: '请输入手机号',
|
||||
},
|
||||
'en-US': {
|
||||
phone: 'Phone',
|
||||
errorInfo: 'Error Info',
|
||||
phoneError: 'Invalid phone',
|
||||
phonePlaceholder: 'Phone',
|
||||
},
|
||||
},
|
||||
|
||||
data() {
|
||||
setup() {
|
||||
const t = useTranslate(i18n);
|
||||
const state = reactive({
|
||||
phone: '123',
|
||||
username: '',
|
||||
});
|
||||
|
||||
return toRefs(state);
|
||||
return {
|
||||
...toRefs(state),
|
||||
t,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -16,34 +16,37 @@
|
||||
</demo-block>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { reactive, toRefs } from 'vue';
|
||||
import { useTranslate } from '@demo/use-translate';
|
||||
|
||||
const i18n = {
|
||||
'zh-CN': {
|
||||
text: '文本',
|
||||
formatValue: '格式化输入内容',
|
||||
formatOnBlur: '在失焦时执行格式化',
|
||||
formatOnChange: '在输入时执行格式化',
|
||||
},
|
||||
'en-US': {
|
||||
text: 'Text',
|
||||
formatValue: 'Format Value',
|
||||
formatOnBlur: 'Format On Blur',
|
||||
formatOnChange: 'Format On Change',
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
i18n: {
|
||||
'zh-CN': {
|
||||
text: '文本',
|
||||
formatValue: '格式化输入内容',
|
||||
formatOnBlur: '在失焦时执行格式化',
|
||||
formatOnChange: '在输入时执行格式化',
|
||||
},
|
||||
'en-US': {
|
||||
text: 'Text',
|
||||
formatValue: 'Format Value',
|
||||
formatOnBlur: 'Format On Blur',
|
||||
formatOnChange: 'Format On Change',
|
||||
},
|
||||
},
|
||||
|
||||
setup() {
|
||||
const t = useTranslate(i18n);
|
||||
const state = reactive({
|
||||
value1: '',
|
||||
value2: '',
|
||||
});
|
||||
const formatter = (value) => value.replace(/\d/g, '');
|
||||
const formatter = (value: string) => value.replace(/\d/g, '');
|
||||
|
||||
return {
|
||||
...toRefs(state),
|
||||
t,
|
||||
formatter,
|
||||
};
|
||||
},
|
||||
|
@ -9,26 +9,29 @@
|
||||
</demo-block>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { useTranslate } from '@demo/use-translate';
|
||||
|
||||
const i18n = {
|
||||
'zh-CN': {
|
||||
text: '文本',
|
||||
inputAlign: '输入框内容对齐',
|
||||
alignPlaceHolder: '输入框内容右对齐',
|
||||
},
|
||||
'en-US': {
|
||||
text: 'Text',
|
||||
inputAlign: 'Input Align',
|
||||
alignPlaceHolder: 'Input Align Right',
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
i18n: {
|
||||
'zh-CN': {
|
||||
text: '文本',
|
||||
inputAlign: '输入框内容对齐',
|
||||
alignPlaceHolder: '输入框内容右对齐',
|
||||
},
|
||||
'en-US': {
|
||||
text: 'Text',
|
||||
inputAlign: 'Input Align',
|
||||
alignPlaceHolder: 'Input Align Right',
|
||||
},
|
||||
},
|
||||
|
||||
setup() {
|
||||
const t = useTranslate(i18n);
|
||||
const value = ref('');
|
||||
return { value };
|
||||
|
||||
return { t, value };
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -16,28 +16,31 @@
|
||||
</demo-block>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { useTranslate } from '@demo/use-translate';
|
||||
|
||||
const i18n = {
|
||||
'zh-CN': {
|
||||
sms: '短信验证码',
|
||||
sendSMS: '发送验证码',
|
||||
insertButton: '插入按钮',
|
||||
smsPlaceholder: '请输入短信验证码',
|
||||
},
|
||||
'en-US': {
|
||||
sms: 'SMS',
|
||||
sendSMS: 'Send SMS',
|
||||
insertButton: 'Insert Button',
|
||||
smsPlaceholder: 'SMS',
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
i18n: {
|
||||
'zh-CN': {
|
||||
sms: '短信验证码',
|
||||
sendSMS: '发送验证码',
|
||||
insertButton: '插入按钮',
|
||||
smsPlaceholder: '请输入短信验证码',
|
||||
},
|
||||
'en-US': {
|
||||
sms: 'SMS',
|
||||
sendSMS: 'Send SMS',
|
||||
insertButton: 'Insert Button',
|
||||
smsPlaceholder: 'SMS',
|
||||
},
|
||||
},
|
||||
|
||||
setup() {
|
||||
const t = useTranslate(i18n);
|
||||
const sms = ref('');
|
||||
return { sms };
|
||||
|
||||
return { t, sms };
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -17,30 +17,35 @@
|
||||
</demo-block>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { reactive, toRefs } from 'vue';
|
||||
import { useTranslate } from '@demo/use-translate';
|
||||
|
||||
const i18n = {
|
||||
'zh-CN': {
|
||||
text: '文本',
|
||||
showIcon: '显示图标',
|
||||
showClearIcon: '显示清除图标',
|
||||
},
|
||||
'en-US': {
|
||||
text: 'Text',
|
||||
showIcon: 'Show Icon',
|
||||
showClearIcon: 'Show Clear Icon',
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
i18n: {
|
||||
'zh-CN': {
|
||||
text: '文本',
|
||||
showIcon: '显示图标',
|
||||
showClearIcon: '显示清除图标',
|
||||
},
|
||||
'en-US': {
|
||||
text: 'Text',
|
||||
showIcon: 'Show Icon',
|
||||
showClearIcon: 'Show Clear Icon',
|
||||
},
|
||||
},
|
||||
|
||||
setup() {
|
||||
const t = useTranslate(i18n);
|
||||
const state = reactive({
|
||||
icon1: '',
|
||||
icon2: '123',
|
||||
});
|
||||
|
||||
return toRefs(state);
|
||||
return {
|
||||
...toRefs(state),
|
||||
t,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
@ -13,26 +13,29 @@
|
||||
</demo-block>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { useTranslate } from '@demo/use-translate';
|
||||
|
||||
const i18n = {
|
||||
'zh-CN': {
|
||||
message: '留言',
|
||||
placeholder: '请输入留言',
|
||||
showWordLimit: '显示字数统计',
|
||||
},
|
||||
'en-US': {
|
||||
message: 'Message',
|
||||
placeholder: 'Message',
|
||||
showWordLimit: 'Show Word Limit',
|
||||
},
|
||||
};
|
||||
|
||||
export default {
|
||||
i18n: {
|
||||
'zh-CN': {
|
||||
message: '留言',
|
||||
placeholder: '请输入留言',
|
||||
showWordLimit: '显示字数统计',
|
||||
},
|
||||
'en-US': {
|
||||
message: 'Message',
|
||||
placeholder: 'Message',
|
||||
showWordLimit: 'Show Word Limit',
|
||||
},
|
||||
},
|
||||
|
||||
setup() {
|
||||
const t = useTranslate(i18n);
|
||||
const value = ref('');
|
||||
return { value };
|
||||
|
||||
return { t, value };
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user