yh-mobile-components 1.3.1 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ - v1.3.4 yhm-select 修复 进行确认操作时,值不更新的问题
2
+ - v1.3.2 yhm-input 修复 input 框没有 focus方法的问题
3
+ - v1.3.1 yhm-select 修复值域下拉选项不匹配导致报错的问题
package/form/yhmInput.vue CHANGED
@@ -7,6 +7,7 @@
7
7
  @keydown="keydownHandler"
8
8
  :type="inputType"
9
9
  :error="error"
10
+ ref="fieldRef"
10
11
  :error-message="errorMessage">
11
12
  <template
12
13
  #right-icon
@@ -28,7 +29,7 @@
28
29
  </van-field>
29
30
  </template>
30
31
  <script setup lang="ts">
31
- import { computed } from "vue";
32
+ import { computed, ref } from "vue";
32
33
  const props = withDefaults(
33
34
  defineProps<{
34
35
  type?: string;
@@ -71,6 +72,16 @@ function keydownHandler(e: KeyboardEvent) {
71
72
  }
72
73
  }
73
74
  }
75
+
76
+ const fieldRef = ref();
77
+ function focus() {
78
+ fieldRef.value?.focus();
79
+ }
80
+
81
+ function blur() {
82
+ fieldRef.value?.blur();
83
+ }
84
+ defineExpose({ fieldRef, focus, blur });
74
85
  </script>
75
86
  <style lang="scss">
76
87
  .yhm-input-container {
@@ -21,9 +21,10 @@
21
21
  <van-picker
22
22
  :title="palceholder"
23
23
  :columns="optionData"
24
- @confirm="onCancel"
25
- @cancel="onCancel"
26
- @change="onChange" />
24
+ :modelValue="[modelValue]"
25
+ ref="pickerRef"
26
+ @confirm="onComfirm"
27
+ @cancel="onCancel" />
27
28
  </van-popup>
28
29
  </template>
29
30
  <script setup lang="ts">
@@ -41,7 +42,8 @@ const emits = defineEmits<{
41
42
 
42
43
  const valueString = computed(() => {
43
44
  if (props.modelValue) {
44
- return props.optionData.filter((item) => item.value === props.modelValue)[0].text;
45
+ let option = props.optionData.filter((item) => item.value === props.modelValue)[0];
46
+ return option ? option.text : props.modelValue;
45
47
  } else {
46
48
  return props.palceholder || "请选择";
47
49
  }
@@ -54,6 +56,7 @@ const valueClass = computed(() => {
54
56
  });
55
57
 
56
58
  const show = ref(false);
59
+ const pickerRef = ref();
57
60
 
58
61
  function toChoose() {
59
62
  if (props.disabled) {
@@ -62,12 +65,17 @@ function toChoose() {
62
65
  show.value = true;
63
66
  }
64
67
 
65
- function onChange({ selectedValues }) {
66
- emits("update:modelValue", selectedValues[0]);
67
- }
68
+ // function onChange({ selectedValues }) {
69
+ // emits("update:modelValue", selectedValues[0]);
70
+ // }
68
71
  function onCancel() {
69
72
  show.value = false;
70
73
  }
74
+
75
+ function onComfirm({ selectedValues }) {
76
+ emits("update:modelValue", selectedValues[0]);
77
+ onCancel();
78
+ }
71
79
  </script>
72
80
  <style lang="scss">
73
81
  .yhm-datetime-container {
@@ -25,8 +25,6 @@
25
25
  </van-field>
26
26
  </template>
27
27
  <script setup lang="ts">
28
- import { computed } from "vue";
29
-
30
28
  const props = withDefaults(
31
29
  defineProps<{
32
30
  error?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yh-mobile-components",
3
- "version": "1.3.1",
3
+ "version": "1.3.4",
4
4
  "description": "移动端组件封装及配置化需求",
5
5
  "main": "index.js",
6
6
  "scripts": {