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>
|
</demo-block>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { ref } from 'vue';
|
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 {
|
export default {
|
||||||
i18n: {
|
|
||||||
'zh-CN': {
|
|
||||||
message: '留言',
|
|
||||||
autosize: '高度自适应',
|
|
||||||
placeholder: '请输入留言',
|
|
||||||
},
|
|
||||||
'en-US': {
|
|
||||||
sms: 'SMS',
|
|
||||||
autosize: 'Auto Resize',
|
|
||||||
placeholder: 'Message',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
const t = useTranslate(i18n);
|
||||||
const value = ref('');
|
const value = ref('');
|
||||||
return { value };
|
|
||||||
|
return { t, value };
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -10,24 +10,26 @@
|
|||||||
</demo-block>
|
</demo-block>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
import { useTranslate } from '@demo/use-translate';
|
||||||
|
|
||||||
|
const i18n = {
|
||||||
|
'zh-CN': {
|
||||||
|
label: '文本',
|
||||||
|
placeholder: '请输入文本',
|
||||||
|
},
|
||||||
|
'en-US': {
|
||||||
|
label: 'Label',
|
||||||
|
placeholder: 'Text',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
i18n: {
|
|
||||||
'zh-CN': {
|
|
||||||
label: '文本',
|
|
||||||
placeholder: '请输入文本',
|
|
||||||
},
|
|
||||||
'en-US': {
|
|
||||||
label: 'Label',
|
|
||||||
placeholder: 'Text',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
const t = useTranslate(i18n);
|
||||||
const value = ref('');
|
const value = ref('');
|
||||||
return { value };
|
return { t, value };
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -32,38 +32,40 @@
|
|||||||
</demo-block>
|
</demo-block>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { reactive, toRefs } from 'vue';
|
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 {
|
export default {
|
||||||
i18n: {
|
setup() {
|
||||||
'zh-CN': {
|
const t = useTranslate(i18n);
|
||||||
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() {
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
text: '',
|
text: '',
|
||||||
phone: '',
|
phone: '',
|
||||||
@ -72,7 +74,10 @@ export default {
|
|||||||
password: '',
|
password: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
return toRefs(state);
|
return {
|
||||||
|
...toRefs(state),
|
||||||
|
t,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -5,20 +5,28 @@
|
|||||||
</demo-block>
|
</demo-block>
|
||||||
</template>
|
</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 {
|
export default {
|
||||||
i18n: {
|
setup() {
|
||||||
'zh-CN': {
|
const t = useTranslate(i18n);
|
||||||
text: '文本',
|
|
||||||
disabled: '禁用输入框',
|
return { t };
|
||||||
inputReadonly: '输入框只读',
|
|
||||||
inputDisabled: '输入框已禁用',
|
|
||||||
},
|
|
||||||
'en-US': {
|
|
||||||
text: 'Text',
|
|
||||||
inputReadonly: 'Input Readonly',
|
|
||||||
inputDisabled: 'Input Disabled',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -17,32 +17,37 @@
|
|||||||
</demo-block>
|
</demo-block>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { reactive, toRefs } from 'vue';
|
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 {
|
export default {
|
||||||
i18n: {
|
setup() {
|
||||||
'zh-CN': {
|
const t = useTranslate(i18n);
|
||||||
phone: '手机号',
|
|
||||||
errorInfo: '错误提示',
|
|
||||||
phoneError: '手机号格式错误',
|
|
||||||
phonePlaceholder: '请输入手机号',
|
|
||||||
},
|
|
||||||
'en-US': {
|
|
||||||
phone: 'Phone',
|
|
||||||
errorInfo: 'Error Info',
|
|
||||||
phoneError: 'Invalid phone',
|
|
||||||
phonePlaceholder: 'Phone',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
data() {
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
phone: '123',
|
phone: '123',
|
||||||
username: '',
|
username: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
return toRefs(state);
|
return {
|
||||||
|
...toRefs(state),
|
||||||
|
t,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -16,34 +16,37 @@
|
|||||||
</demo-block>
|
</demo-block>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { reactive, toRefs } from 'vue';
|
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 {
|
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() {
|
setup() {
|
||||||
|
const t = useTranslate(i18n);
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
value1: '',
|
value1: '',
|
||||||
value2: '',
|
value2: '',
|
||||||
});
|
});
|
||||||
const formatter = (value) => value.replace(/\d/g, '');
|
const formatter = (value: string) => value.replace(/\d/g, '');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...toRefs(state),
|
...toRefs(state),
|
||||||
|
t,
|
||||||
formatter,
|
formatter,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -9,26 +9,29 @@
|
|||||||
</demo-block>
|
</demo-block>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { ref } from 'vue';
|
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 {
|
export default {
|
||||||
i18n: {
|
|
||||||
'zh-CN': {
|
|
||||||
text: '文本',
|
|
||||||
inputAlign: '输入框内容对齐',
|
|
||||||
alignPlaceHolder: '输入框内容右对齐',
|
|
||||||
},
|
|
||||||
'en-US': {
|
|
||||||
text: 'Text',
|
|
||||||
inputAlign: 'Input Align',
|
|
||||||
alignPlaceHolder: 'Input Align Right',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
const t = useTranslate(i18n);
|
||||||
const value = ref('');
|
const value = ref('');
|
||||||
return { value };
|
|
||||||
|
return { t, value };
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -16,28 +16,31 @@
|
|||||||
</demo-block>
|
</demo-block>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { ref } from 'vue';
|
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 {
|
export default {
|
||||||
i18n: {
|
|
||||||
'zh-CN': {
|
|
||||||
sms: '短信验证码',
|
|
||||||
sendSMS: '发送验证码',
|
|
||||||
insertButton: '插入按钮',
|
|
||||||
smsPlaceholder: '请输入短信验证码',
|
|
||||||
},
|
|
||||||
'en-US': {
|
|
||||||
sms: 'SMS',
|
|
||||||
sendSMS: 'Send SMS',
|
|
||||||
insertButton: 'Insert Button',
|
|
||||||
smsPlaceholder: 'SMS',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
const t = useTranslate(i18n);
|
||||||
const sms = ref('');
|
const sms = ref('');
|
||||||
return { sms };
|
|
||||||
|
return { t, sms };
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -17,30 +17,35 @@
|
|||||||
</demo-block>
|
</demo-block>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { reactive, toRefs } from 'vue';
|
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 {
|
export default {
|
||||||
i18n: {
|
|
||||||
'zh-CN': {
|
|
||||||
text: '文本',
|
|
||||||
showIcon: '显示图标',
|
|
||||||
showClearIcon: '显示清除图标',
|
|
||||||
},
|
|
||||||
'en-US': {
|
|
||||||
text: 'Text',
|
|
||||||
showIcon: 'Show Icon',
|
|
||||||
showClearIcon: 'Show Clear Icon',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
const t = useTranslate(i18n);
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
icon1: '',
|
icon1: '',
|
||||||
icon2: '123',
|
icon2: '123',
|
||||||
});
|
});
|
||||||
|
|
||||||
return toRefs(state);
|
return {
|
||||||
|
...toRefs(state),
|
||||||
|
t,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -13,26 +13,29 @@
|
|||||||
</demo-block>
|
</demo-block>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { ref } from 'vue';
|
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 {
|
export default {
|
||||||
i18n: {
|
|
||||||
'zh-CN': {
|
|
||||||
message: '留言',
|
|
||||||
placeholder: '请输入留言',
|
|
||||||
showWordLimit: '显示字数统计',
|
|
||||||
},
|
|
||||||
'en-US': {
|
|
||||||
message: 'Message',
|
|
||||||
placeholder: 'Message',
|
|
||||||
showWordLimit: 'Show Word Limit',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
const t = useTranslate(i18n);
|
||||||
const value = ref('');
|
const value = ref('');
|
||||||
return { value };
|
|
||||||
|
return { t, value };
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user