Skip to content

Commit

Permalink
perf: dynamic options demo
Browse files Browse the repository at this point in the history
  • Loading branch information
ckl1 committed Jul 1, 2022
1 parent 5e292f8 commit 9a3b617
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/config/axios/index.ts
Expand Up @@ -25,6 +25,8 @@ service.interceptors.request.use(
) {
config.data = qs.stringify(config.data)
}
// 添加token,可根据实际业务修改
// config!.headers!['Authorization'] = 'something'
// get参数编码
if (config.method === 'get' && config.params) {
let url = config.url as string
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en.ts
Expand Up @@ -341,7 +341,8 @@ export default {
position: 'position',
left: 'left',
center: 'center',
right: 'right'
right: 'right',
dynamicOptions: 'Dynamic options'
},
stickyDemo: {
sticky: 'Sticky'
Expand Down
3 changes: 2 additions & 1 deletion src/locales/zh-CN.ts
Expand Up @@ -338,7 +338,8 @@ export default {
position: '位置',
left: '左',
center: '中',
right: '右'
right: '右',
dynamicOptions: '动态选项'
},
stickyDemo: {
sticky: '黏性'
Expand Down
12 changes: 12 additions & 0 deletions src/views/Components/Search.vue
Expand Up @@ -5,6 +5,7 @@ import { Search } from '@/components/Search'
import { reactive, ref, unref } from 'vue'
import { useValidator } from '@/hooks/web/useValidator'
import { ElButton } from 'element-plus'
import { getDictOneApi } from '@/api/common'
const { required } = useValidator()
Expand Down Expand Up @@ -174,6 +175,14 @@ const changePosition = (position: string) => {
layout.value = 'bottom'
buttomPosition.value = position
}
const getDictOne = async () => {
const res = await getDictOneApi()
if (res) {
schema[1].componentProps!.options = res.data
console.log(res.data)
}
}
</script>

<template>
Expand All @@ -196,6 +205,9 @@ const changePosition = (position: string) => {
<ElButton @click="changePosition('right')">
{{ t('searchDemo.bottom') }} {{ t('searchDemo.position') }}-{{ t('searchDemo.right') }}
</ElButton>
<ElButton @click="getDictOne">
{{ t('searchDemo.dynamicOptions') }}
</ElButton>
</ContentWrap>

<ContentWrap :title="t('searchDemo.search')" :message="t('searchDemo.searchDes')">
Expand Down

0 comments on commit 9a3b617

Please sign in to comment.