Skip to content

Commit 4fa6790

Browse files
committed
docs: add change-compat faq docs
1 parent 2588b14 commit 4fa6790

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

examples/sites/demos/pc/webdoc/faq-en.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,43 @@ export default defineConfig({
3333
}
3434
})
3535
```
36+
37+
## 3、Configure `change-compat` to `true` to trigger the event
38+
39+
By default, when the code logic changes the value of the responsive variable, the component will not trigger the corresponding event. For example, when the `current-page` of the `Pager` is modified, the `current-change` event will not be triggered. The corresponding event will be triggered only after the interaction occurs.
40+
You can set `change-compat` to `true` to trigger the event in the above situation.
41+
42+
```html
43+
<template>
44+
<div>
45+
<tiny-button @click="currentPage = 1">change current-page</tiny-button>
46+
<tiny-pager
47+
:total="100"
48+
:current-page="currentPage"
49+
mode="number"
50+
change-compat
51+
@current-change="dataChangeTrigger"
52+
></tiny-pager>
53+
</div>
54+
</template>
55+
56+
<script setup>
57+
import { ref } from 'vue'
58+
import { TinyPager, TinyModal, TinyButton } from '@opentiny/vue'
59+
60+
const currentPage = ref(10)
61+
62+
const dataChangeTrigger = () => {
63+
TinyModal.message({
64+
message: 'current-change is triggered',
65+
status: 'info'
66+
})
67+
}
68+
</script>
69+
70+
<style scoped>
71+
.tiny-button {
72+
margin-bottom: 12px;
73+
}
74+
</style>
75+
```

examples/sites/demos/pc/webdoc/faq.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,43 @@ export default defineConfig({
3333
}
3434
})
3535
```
36+
37+
## 3、配置 `change-compat``true` 触发事件
38+
39+
默认情况下,代码逻辑更改响应式变量的值,组件不会触发对应事件,例如当修改 `Pager` 组件的 `current-page` 时,不会触发 `current-change` 事件。仅当交互行为发生后,才会触发对应事件。
40+
可以将 `change-compat` 设置为 `true` 在上述情况下触发事件。
41+
42+
```html
43+
<template>
44+
<div>
45+
<tiny-button @click="currentPage = 1">改变current-page</tiny-button>
46+
<tiny-pager
47+
:total="100"
48+
:current-page="currentPage"
49+
mode="number"
50+
change-compat
51+
@current-change="dataChangeTrigger"
52+
></tiny-pager>
53+
</div>
54+
</template>
55+
56+
<script setup>
57+
import { ref } from 'vue'
58+
import { TinyPager, TinyModal, TinyButton } from '@opentiny/vue'
59+
60+
const currentPage = ref(10)
61+
62+
const dataChangeTrigger = () => {
63+
TinyModal.message({
64+
message: 'current-change 事件触发',
65+
status: 'info'
66+
})
67+
}
68+
</script>
69+
70+
<style scoped>
71+
.tiny-button {
72+
margin-bottom: 12px;
73+
}
74+
</style>
75+
```

0 commit comments

Comments
 (0)