docs: improve description of date-picker value-format prop (#2416) (#2449)

This commit is contained in:
msidolphin 2021-07-06 15:36:38 +08:00 committed by GitHub
parent 3d161f785a
commit 4622b12869
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 130 additions and 7 deletions

View File

@ -292,7 +292,7 @@ export default defineComponent({
if (Array.isArray(props.modelValue)) {
result = props.modelValue.map(_=> parser(_, props.valueFormat))
} else {
result = parser(props.modelValue as Date, props.valueFormat)
result = parser(props.modelValue, props.valueFormat)
}
}

View File

@ -485,7 +485,7 @@ If type is `daterange`, `default-value` sets the left side calendar.
:::
### Date Formats
Use `format` to control displayed text's format in the input box.
Use `format` to control displayed text's format in the input box. Use `value-format` to control binding value's format.
By default, the component accepts and emits a `Date` object.
@ -519,6 +519,17 @@ Pay attention to capitalization
value-format="YYYY-MM-DD">
</el-date-picker>
</div>
<div class="block">
<span class="demonstration">Timestamp</span>
<div class="demonstration">Value{{ value3 }}</div>
<el-date-picker
v-model="value3"
type="date"
placeholder="Pick a Date"
format="YYYY/MM/DD"
value-format="x">
</el-date-picker>
</div>
</template>
<script>
@ -526,7 +537,8 @@ Pay attention to capitalization
data() {
return {
value1: '',
value2: ''
value2: '',
value3: ''
};
}
};
@ -540,10 +552,12 @@ Pay attention to capitalization
setup() {
const value1 = ref('');
const value2 = ref('');
const value3 = ref('');
return {
value1,
value2,
value3,
};
},
});

View File

@ -487,7 +487,7 @@ Si el tipo es `daterange`, `default-value` establece el calendario del lado izqu
:::
### Formatos de Date
Utilice `format` para controlar el formato del texto visualizado en el input.
Utilice `format` para controlar el formato del texto visualizado en el input. Utilice `value-format` para controlar el formato del valor vinculado.
Por defecto, el componente acepta y emite un objeto Date.
@ -521,6 +521,17 @@ Preste atención a la capitalización
value-format="YYYY-MM-DD">
</el-date-picker>
</div>
<div class="block">
<span class="demonstration">Timestamp</span>
<div class="demonstration">Value{{ value3 }}</div>
<el-date-picker
v-model="value3"
type="date"
placeholder="Pick a Date"
format="YYYY/MM/DD"
value-format="x">
</el-date-picker>
</div>
</template>
<script>
@ -534,6 +545,27 @@ Preste atención a la capitalización
}
};
</script>
<!--
<setup>
import { defineComponent, ref } from 'vue';
export default defineComponent({
setup() {
const value1 = ref('');
const value2 = ref('');
const value3 = ref('');
return {
value1,
value2,
value3,
};
},
});
</setup>
-->
```
:::

View File

@ -485,7 +485,7 @@ Si le type est `daterange`, `default-value` configure la panneau de gauche.
### Formats de date
Utilisez `format` pour contrôler l'affichage de la date dans le champ.
Utilisez `format` pour contrôler l'affichage de la date dans le champ. Utilisez `value-format` pour contrôler le format de la variable stockée.
Par défaut, le composant accepte et émet un objet `Date`.
@ -519,6 +519,17 @@ Attention à la capitalisation !
value-format="YYYY-MM-DD">
</el-date-picker>
</div>
<div class="block">
<span class="demonstration">Timestamp</span>
<div class="demonstration">Value{{ value3 }}</div>
<el-date-picker
v-model="value3"
type="date"
placeholder="Sélectionnez une date"
format="YYYY/MM/DD"
value-format="x">
</el-date-picker>
</div>
</template>
<script>
@ -532,6 +543,27 @@ Attention à la capitalisation !
}
};
</script>
<!--
<setup>
import { defineComponent, ref } from 'vue';
export default defineComponent({
setup() {
const value1 = ref('');
const value2 = ref('');
const value3 = ref('');
return {
value1,
value2,
value3,
};
},
});
</setup>
-->
```
:::

View File

@ -481,7 +481,7 @@
:::
### 日付のフォーマット
入力ボックスに表示されるテキストの書式を制御するには `format` を用いる。
入力ボックスに表示されるテキストの書式を制御するには `format` を用いる。Use `value-format` to control binding value's format.
デフォルトでは、コンポーネントは `Date` オブジェクトを受け入れて出力します。
@ -515,6 +515,17 @@ Check the list [here](https://day.js.org/docs/en/display/format#list-of-all-avai
value-format="YYYY-MM-DD">
</el-date-picker>
</div>
<div class="block">
<span class="demonstration">Timestamp</span>
<div class="demonstration">Value{{ value3 }}</div>
<el-date-picker
v-model="value3"
type="date"
placeholder="Pick a Date"
format="YYYY/MM/DD"
value-format="x">
</el-date-picker>
</div>
</template>
<script>
@ -528,6 +539,27 @@ Check the list [here](https://day.js.org/docs/en/display/format#list-of-all-avai
}
};
</script>
<!--
<setup>
import { defineComponent, ref } from 'vue';
export default defineComponent({
setup() {
const value1 = ref('');
const value2 = ref('');
const value3 = ref('');
return {
value1,
value2,
value3,
};
},
});
</setup>
-->
```
:::

View File

@ -482,7 +482,7 @@ import { defineComponent, reactive, toRefs } from 'vue';
### 日期格式
使用`format`指定输入框的格式。
使用`format`指定输入框的格式。使用`value-format`指定绑定值的格式。
默认情况下,组件接受并返回`Date`对象。
@ -516,6 +516,17 @@ import { defineComponent, reactive, toRefs } from 'vue';
value-format="YYYY/MM/DD">
</el-date-picker>
</div>
<div class="block">
<span class="demonstration">时间戳</span>
<div class="demonstration">值:{{ value3 }}</div>
<el-date-picker
v-model="value3"
type="date"
placeholder="选择日期"
format="YYYY 年 MM 月 DD 日"
value-format="x">``
</el-date-picker>
</div>
</template>
<script>
@ -524,6 +535,7 @@ import { defineComponent, reactive, toRefs } from 'vue';
return {
value1: '',
value2: '',
value3: ''
};
}
};
@ -538,6 +550,7 @@ import { defineComponent, ref } from 'vue';
return {
value1: ref(''),
value2: ref(''),
value3: ref('')
};
},
});